date_time_precision 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab8750ef80131b6e004a6a94f09a05edc2841f4c
|
4
|
+
data.tar.gz: f0d05d213fc283079b3e605df868995fae7db6a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5050a7386517ab4e70dda7c65098f8f06911a64ee2c7e1735aa93e3f794aa03eb75b5b79aea2ba7fe4da00ba652aba974563e3de6852a9ce80e7fb34b9457b1
|
7
|
+
data.tar.gz: 64192f5761fcb0037403c7b66268f268de1edf35a11b43bb89b52a97acb5a1a7f443477d269710b10332ebee4b8950f113a471b8fe05af802071f8ef9a329010
|
@@ -2,8 +2,8 @@ require 'date_time_precision/lib'
|
|
2
2
|
|
3
3
|
class Hash
|
4
4
|
DATE_FORMATS = {
|
5
|
-
:short => [:y, :m, :d],
|
6
|
-
:long => [:year, :month, :day],
|
5
|
+
:short => [:y, :m, :d, :h, :min, :s, :sec_frac],
|
6
|
+
:long => [:year, :month, :day, :hour, :minute, :second, :second_fraction],
|
7
7
|
:ruby => [:year, :mon, :day, :hour, :min, :sec, :sec_frac]
|
8
8
|
}
|
9
9
|
DATE_FORMATS[:default] = DATE_FORMATS[:ruby]
|
@@ -26,9 +26,9 @@ class Hash
|
|
26
26
|
self[:mon] || self[:m] || self[:month] || self['mon'] || self['m'] || self['month'],
|
27
27
|
self[:mday] || self[:d] || self[:day] || self['mday'] || self['d'] || self['day'],
|
28
28
|
self[:hour] || self[:h] || self[:hr] || self['hour'] || self['h'] || self['hr'],
|
29
|
-
self[:min] || self['min'],
|
30
|
-
self[:sec] || self[:s] || self['sec'] || self['s'],
|
31
|
-
self[:sec_frac] || self['sec_frac']]
|
29
|
+
self[:min] || self[:minute] || self['min'] || self["minute"],
|
30
|
+
self[:sec] || self[:s] || self[:second] || self['sec'] || self['s'] || self["second"],
|
31
|
+
self[:sec_frac] || self[:second_fraction] || self['sec_frac'] || self['second_fraction']]
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -277,9 +277,31 @@ describe DateTimePrecision do
|
|
277
277
|
it 'should convert Date to a short hash' do
|
278
278
|
date.to_h(:short).should == short_date_hash
|
279
279
|
end
|
280
|
+
|
281
|
+
it 'should convert Date to a long hash' do
|
282
|
+
date.to_h(:long).should == long_date_hash
|
283
|
+
end
|
280
284
|
|
281
285
|
it 'should convert DateTime to a long hash' do
|
282
|
-
datetime.to_h(:long).should ==
|
286
|
+
datetime.to_h(:long).should == {
|
287
|
+
:year => 1989,
|
288
|
+
:month => 3,
|
289
|
+
:day => 11,
|
290
|
+
:hour => 8,
|
291
|
+
:minute => 30,
|
292
|
+
:second => 15
|
293
|
+
}
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'should convert Time to a short hash' do
|
297
|
+
time.to_h(:short).should == {
|
298
|
+
:y => 1989,
|
299
|
+
:m => 3,
|
300
|
+
:d => 11,
|
301
|
+
:h => 8,
|
302
|
+
:min => 30,
|
303
|
+
:s => 15
|
304
|
+
}
|
283
305
|
end
|
284
306
|
|
285
307
|
it 'should convert Time to a custom hash' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date_time_precision
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Butler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|