It seems strange that "2010--9-12 3:12pm" is a weak spot of Chronic Rubygem? Is there a way to make it work? (or another gem that can do it?) I also hope to find a parser that can handle 2010-09-12 3:12pm UTC
or other timezones such as PDT
, PST
, or UTC+8
or -0700
irb(main):001:0> RUBY_VERSION
=> "1.8.7"
irb(main):002:0> require 'rubygems'
=> true
irb(main):003:0> require 'chronic'
=> true
irb(main):004:0> Chronic.parse('9/12/2010')
=> Sun Sep 12 12:00:00 -0700 2010
irb(main):005:0> Chronic.parse('9/12/2010 3pm')
=> Sun Sep 12 15:00:00 -0700 2010
irb(main):006:0> Chronic.parse('9/12/2010 3:12pm') # <-- cannot work
=> nil
irb(main):007:0> Chronic.parse('last monday 3:12pm')
=> Mon Sep 06 15:12:00 -0700 2010
irb(main):008:0> Chronic.parse('2010-09-12')
=> Sun Sep 12 12:00:00 -0700 2010
irb(main):009:0> Chronic.parse('2010-09-12 3:12pm') # <-- cannot work
=> nil
It works for me using latest
Chronic
on Github on Ruby 1.8.7 (2009-06-12 patchlevel 174):In the test suite there are tests for:
But not exact match to your problem date(s). So if you have discovered a bug then it might be worth telling Chronic's author so that he can update the tests.
BTW... what do you get when you try:
Because I get the correct:
Sun Sep 12 15:12:00 +0100 2010
(NB. I'm in day light saving time here). I mention this because I saw a ambiguous tweet this morning about problem with time API in a minor point release./I3az/