smarter_dates 0.2.7.12 → 0.2.7.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/smarter_dates/parser.rb +5 -3
- data/lib/smarter_dates/version.rb +1 -1
- data/test/smarter_dates_test.rb +3 -0
- metadata +1 -1
data/lib/smarter_dates/parser.rb
CHANGED
@@ -44,11 +44,13 @@ def self.included( klass ) # :nodoc:
|
|
44
44
|
rescue
|
45
45
|
dt = val
|
46
46
|
end
|
47
|
-
if defined?(Rails)
|
48
|
-
if k.match(/_(?:on|d)$/)
|
47
|
+
if defined?(Rails)
|
48
|
+
if dt && k.match(/_(?:on|d)$/)
|
49
49
|
self[k] = dt.to_date
|
50
|
-
|
50
|
+
elsif dt
|
51
51
|
self[k] = dt.to_datetime
|
52
|
+
else
|
53
|
+
self[k] = dt
|
52
54
|
end
|
53
55
|
else
|
54
56
|
instance_variable_set(:"@#{k}",dt)
|
data/test/smarter_dates_test.rb
CHANGED
@@ -56,6 +56,9 @@ class SmarterDatesTest < Test::Unit::TestCase
|
|
56
56
|
@model.birth_d = "32 April 1976"
|
57
57
|
assert_equal nil, @model.birth_d
|
58
58
|
|
59
|
+
@model.birth_d = nil
|
60
|
+
assert_equal nil, @model.birth_d
|
61
|
+
|
59
62
|
# TODO: fix this in chronic
|
60
63
|
if false
|
61
64
|
@model.birth_d = "30 Feb 1976"
|