ohm-contrib 0.0.30 → 0.0.31
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.
- data/VERSION +1 -1
- data/lib/ohm/contrib/typecast.rb +1 -10
- data/lib/ohm/contrib.rb +1 -1
- data/ohm-contrib.gemspec +1 -1
- data/test/test_ohm_typecast.rb +7 -16
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.31
|
data/lib/ohm/contrib/typecast.rb
CHANGED
@@ -111,17 +111,8 @@ module Ohm
|
|
111
111
|
class Time < Primitive
|
112
112
|
delegate_to ::Time
|
113
113
|
|
114
|
-
YYYY_MM_DD = /\A([0-9]{4})-([01]?[0-9])-([0123]?[0-9])\z/
|
115
|
-
YYYY_MM_DD_HH_MM_SS = /\A([0-9]{4})-([01]?[0-9])-([0123]?[0-9]) ([\d]{1,2}):([\d]{1,2})(:([\d]{1,2}))?\z/
|
116
|
-
|
117
114
|
def object
|
118
|
-
|
119
|
-
::Time.utc($1, $2, $3)
|
120
|
-
elsif @raw =~ YYYY_MM_DD_HH_MM_SS
|
121
|
-
::Time.utc($1, $2, $3, $4, $5, $7)
|
122
|
-
else
|
123
|
-
::Time.parse(@raw)
|
124
|
-
end
|
115
|
+
::Time.parse(@raw).utc
|
125
116
|
end
|
126
117
|
end
|
127
118
|
|
data/lib/ohm/contrib.rb
CHANGED
data/ohm-contrib.gemspec
CHANGED
data/test/test_ohm_typecast.rb
CHANGED
@@ -262,7 +262,7 @@ class TestOhmTypecast < Test::Unit::TestCase
|
|
262
262
|
end
|
263
263
|
|
264
264
|
test "allows for real time operations" do
|
265
|
-
post = Post.create(:created_at => "2010-05-
|
265
|
+
post = Post.create(:created_at => "2010-05-10T00:00Z")
|
266
266
|
post = Post[post.id]
|
267
267
|
|
268
268
|
assert_respond_to post.created_at, :strftime
|
@@ -296,8 +296,8 @@ class TestOhmTypecast < Test::Unit::TestCase
|
|
296
296
|
attribute :printed_at, Time
|
297
297
|
end
|
298
298
|
|
299
|
-
test "2010-08-
|
300
|
-
post = Post.new(:printed_at => "2010-08-
|
299
|
+
test "2010-08-07T00:00Z is parsed as 2010-08-07 00:00:00 UTC" do
|
300
|
+
post = Post.new(:printed_at => "2010-08-07T00:00Z")
|
301
301
|
assert_equal Time.utc(2010, 8, 7).to_s, post.printed_at.utc.to_s
|
302
302
|
|
303
303
|
post.save
|
@@ -305,17 +305,8 @@ class TestOhmTypecast < Test::Unit::TestCase
|
|
305
305
|
assert_equal Time.utc(2010, 8, 7).to_s, post.printed_at.utc.to_s
|
306
306
|
end
|
307
307
|
|
308
|
-
test "2010-08-07
|
309
|
-
post = Post.new(:printed_at => "2010-08-07
|
310
|
-
assert_equal Time.utc(2010, 8, 7).to_s, post.printed_at.utc.to_s
|
311
|
-
|
312
|
-
post.save
|
313
|
-
post = Post[post.id]
|
314
|
-
assert_equal Time.utc(2010, 8, 7).to_s, post.printed_at.utc.to_s
|
315
|
-
end
|
316
|
-
|
317
|
-
test "2010-08-07 18:29 is parsed as 2010-08-07 18:29:00 UTC" do
|
318
|
-
post = Post.new(:printed_at => "2010-08-07 18:29")
|
308
|
+
test "2010-08-07 18:29Z is parsed as 2010-08-07 18:29:00 UTC" do
|
309
|
+
post = Post.new(:printed_at => "2010-08-07 18:29Z")
|
319
310
|
assert_equal Time.utc(2010, 8, 7, 18, 29).to_s, post.printed_at.utc.to_s
|
320
311
|
|
321
312
|
post.save
|
@@ -323,8 +314,8 @@ class TestOhmTypecast < Test::Unit::TestCase
|
|
323
314
|
assert_equal Time.utc(2010, 8, 7, 18, 29).to_s, post.printed_at.utc.to_s
|
324
315
|
end
|
325
316
|
|
326
|
-
test "2010-08-
|
327
|
-
post = Post.new(:printed_at => "2010-08-
|
317
|
+
test "2010-08-07T18:29:31Z is parsed as 2010-08-07 18:29:31 UTC" do
|
318
|
+
post = Post.new(:printed_at => "2010-08-07T18:29:31Z")
|
328
319
|
assert_equal Time.utc(2010, 8, 7, 18, 29, 31).to_s, post.printed_at.utc.to_s
|
329
320
|
|
330
321
|
post.save
|