Method: String#to_chronic_datetime
- Defined in:
- lib/smarter_dates/chronic_strings.rb
#to_chronic_datetime ⇒ Object
:call-seq: to_chronic_datetime
Parses a string into a DateTime object using the Chronic gem if available. If not, try parsing the string using :parse_with_builtins raise an error if the string fails to parse
10 11 12 13 14 15 |
# File 'lib/smarter_dates/chronic_strings.rb', line 10 def to_chronic_datetime dt = defined?(Chronic) ? parse_with_chronic : parse_with_builtins #raise RuntimeError, "#{dt.inspect} unparsable Date/DateTime" unless dt return unless dt dt.to_datetime end |