date_helper 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -2
- data/date_helper.gemspec +1 -1
- data/lib/date_helper.rb +18 -1
- data/spec/lib/date_helper_spec.rb +6 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f977cb78a18493fcb28e534d2e0f5e30501463f
|
4
|
+
data.tar.gz: 8a6264ece452c352e7849a2096dca7208ce4772f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84e304352391135b5a2547319d6e04165f0dc20fa3b5d9f3c4838c209429d68f287d72ca2f789741292fcb6d52e4a4e7588ecb26f55367f9703e46c36afc148d
|
7
|
+
data.tar.gz: 766dde9d476939255ed1eae4b90ace80ca36ec29b73aeea2b85794e227a7008c98c1094bc8a93062a218f1be460efbd66db2fe0521340da58fa98b0f67844a06
|
data/README.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# DateHelper
|
2
2
|
|
3
|
-
Adds
|
3
|
+
Adds some useful methods to the `Date` class.
|
4
4
|
|
5
|
-
`months_between`
|
5
|
+
### `months_between`
|
6
|
+
|
7
|
+
Class method `months_between` returns an array of `Date` objects for the first day of each month, inclusive of the starting and ending months.
|
8
|
+
|
9
|
+
### `to_utc_time`
|
10
|
+
|
11
|
+
Instance method `to_utc_time` converts a given `Date` instance to a `Time` object at 00:00:00 UTC on the given `Date`
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
@@ -24,7 +30,14 @@ xmas = Date.parse("2013-12-25")
|
|
24
30
|
hksar_establishment_day = Date.parse("2014-07-01")
|
25
31
|
|
26
32
|
Date.months_between(xmas,hksar_establishment_day)
|
33
|
+
=> [Sun, 01 Dec 2013, Wed, 01 Jan 2014, Sat, 01 Feb 2014, Sat, 01 Mar 2014, Tue, 01 Apr 2014, Thu, 01 May 2014, Sun, 01 Jun 2014, Tue, 01 Jul 2014]
|
27
34
|
```
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Date.parse("2014-04-27").to_utc_time
|
38
|
+
=> 2014-04-27 00:00:00 UTC
|
39
|
+
```
|
40
|
+
|
28
41
|
## Contributing
|
29
42
|
|
30
43
|
1. Fork it
|
data/date_helper.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = DateHelper::VERSION
|
9
9
|
spec.authors = ["Larry Salibra"]
|
10
10
|
spec.email = ["larry@pay4bugs.com"]
|
11
|
-
spec.description = "Adds
|
11
|
+
spec.description = "Adds some useful methods to the Date class."
|
12
12
|
spec.summary = spec.description
|
13
13
|
spec.homepage = "https://github.com/pay4bugs/date_helper"
|
14
14
|
spec.license = "MIT"
|
data/lib/date_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'date'
|
2
2
|
|
3
3
|
module DateHelper
|
4
|
-
VERSION = "1.
|
4
|
+
VERSION = "1.1.0"
|
5
5
|
end
|
6
6
|
|
7
7
|
class Date
|
@@ -24,4 +24,21 @@ class Date
|
|
24
24
|
|
25
25
|
months << end_date
|
26
26
|
end
|
27
|
+
|
28
|
+
|
29
|
+
def self.utc_times(dates)
|
30
|
+
result = Array.new
|
31
|
+
for date in dates
|
32
|
+
result << date.to_utc_time
|
33
|
+
end
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
# return a Time object at 00:00:00 UTC on the given Date
|
39
|
+
def to_utc_time
|
40
|
+
Time.utc(self.year,self.month,self.day)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
27
44
|
end
|
@@ -85,5 +85,11 @@ describe DateHelper do
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
+
|
89
|
+
|
90
|
+
it "to_utc_time should convert date to utc time" do
|
91
|
+
expect(Date.parse("2014-01-01").to_utc_time).to be == Time.iso8601("2014-01-01T00:00:00Z")
|
92
|
+
expect(Date.parse("2014-01-01").to_time).to_not be == Time.iso8601("2014-01-01T00:00:00Z")
|
93
|
+
end
|
88
94
|
|
89
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Larry Salibra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description: Adds
|
55
|
+
description: Adds some useful methods to the Date class.
|
56
56
|
email:
|
57
57
|
- larry@pay4bugs.com
|
58
58
|
executables: []
|
@@ -90,6 +90,6 @@ rubyforge_project:
|
|
90
90
|
rubygems_version: 2.1.8
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
|
-
summary: Adds
|
93
|
+
summary: Adds some useful methods to the Date class.
|
94
94
|
test_files:
|
95
95
|
- spec/lib/date_helper_spec.rb
|