time_it 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +60 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/core_ext/time.rb +17 -0
- data/lib/time_it/version.rb +3 -0
- data/lib/time_it.rb +5 -0
- data/time_it.gemspec +24 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 73fa9c5f417c0b9c0a3b2dace61085e9a139b7de
|
4
|
+
data.tar.gz: 9a9f50609c33f5d97684ec86eea0dfeea5a435fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 27b5f1658e0ca76f09886718ad3d9ffd5be1af7f4369a67ae9acc74016386f374b0297243146d92996af9f4b79c216a56f509419f21ae6139191c2d8682d9b47
|
7
|
+
data.tar.gz: 54c7c550fbc4fd7727ef5dd3c3f28e3d999b48b9a33a25f461fb76b2be926797973de1b9e5bb30e0f1dd11c1905ff7c70ad0836e0a40aa0729374fa005c61a19
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# TimeIt
|
2
|
+
|
3
|
+
Helpers and extensions to improve working with Time.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'time_it'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install time_it
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
**#at**
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# this is the regular at in Time class
|
27
|
+
time = Time.at(1463529600)
|
28
|
+
# => 2016-05-18 02:00:00 +0200
|
29
|
+
|
30
|
+
# This is the extension
|
31
|
+
time.at(hour: 12)
|
32
|
+
# => 2016-05-18 12:00:00 +0200
|
33
|
+
time.at(hour: 12, min: 40)
|
34
|
+
# => 2016-05-18 12:40:00 +0200
|
35
|
+
|
36
|
+
# original instance is not modified
|
37
|
+
time
|
38
|
+
# => 2016-05-18 02:00:00 +0200
|
39
|
+
```
|
40
|
+
**#to_h**
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# this is the regular at in Time class
|
44
|
+
time = Time.at(1463529600)
|
45
|
+
# => 2016-05-18 02:00:00 +0200
|
46
|
+
|
47
|
+
# This is the extension
|
48
|
+
time.to_h
|
49
|
+
# => {:sec=>0, :min=>0, :hour=>2, :day=>18, :month=>5, :year=>2016, :wday=>3, :yday=>139, :isdst=>true, :zone=>"CEST"}
|
50
|
+
```
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/time_it.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "time_it"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class Time
|
2
|
+
ToHKeys = %i{sec min hour day month year wday yday isdst zone}.freeze
|
3
|
+
def at(args = {})
|
4
|
+
norm = to_h.merge(args)
|
5
|
+
utc_offset = args[:utc_offset] || strftime('%:z')
|
6
|
+
ary = [
|
7
|
+
norm[:year], norm[:month], norm[:day],
|
8
|
+
norm[:hour], norm[:min], norm[:sec],
|
9
|
+
utc_offset
|
10
|
+
]
|
11
|
+
self.class.new(*ary)
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_h
|
15
|
+
Hash[ToHKeys.zip self.to_a]
|
16
|
+
end
|
17
|
+
end
|
data/lib/time_it.rb
ADDED
data/time_it.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'time_it/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "time_it"
|
8
|
+
spec.version = TimeIt::VERSION
|
9
|
+
spec.authors = ["Artur Pañach"]
|
10
|
+
spec.email = ["arturictus@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Helpers and extensions to improve working with Time.}
|
13
|
+
spec.description = %q{Helpers and extensions to improve working with Time.}
|
14
|
+
spec.homepage = "https://github.com/arturictus/time_it"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: time_it
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Artur Pañach
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Helpers and extensions to improve working with Time.
|
56
|
+
email:
|
57
|
+
- arturictus@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- lib/core_ext/time.rb
|
70
|
+
- lib/time_it.rb
|
71
|
+
- lib/time_it/version.rb
|
72
|
+
- time_it.gemspec
|
73
|
+
homepage: https://github.com/arturictus/time_it
|
74
|
+
licenses: []
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.6.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Helpers and extensions to improve working with Time.
|
96
|
+
test_files: []
|