string_date_accessors 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/string_date_accessors.rb +3 -2
- data/string_date_accessors.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'date'
|
2
|
+
require 'active_support'
|
2
3
|
module StringDateAccessors
|
3
4
|
def self.date_format=(string)
|
4
5
|
@date_format = string
|
@@ -21,8 +22,8 @@ module StringDateAccessors
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def self.formatted(input)
|
24
|
-
DateTime.strptime(input, datetime_format)
|
25
|
-
rescue ArgumentError
|
25
|
+
DateTime.strptime(input, datetime_format).to_time
|
26
|
+
rescue ArgumentError, NoMethodError
|
26
27
|
begin
|
27
28
|
Date.strptime(input, date_format)
|
28
29
|
rescue ArgumentError
|