I stumbled upon an interesting (and for quit some time puzzling) behavior using the Chronic gem.
Parsing the string 1/21/13 2:20
:
Chronic.parse('1/21/13 2:20')
=> 2013-01-21 14:20:00 -0800
However, if a 0
is place in front of the 2
:
Chronic.parse('1/21/13 02:20')
=> 2013-01-21 02:20:00 -0800
Now, I can put AM or PM at the end of the string, which essentially overrides this behavior (so it doesn't matter whether the leading 0
is present), but that is obviously an extra step of parsing, and negates much of the advantage of using Chronic. Is there another option to deal with this leading zero problem appropriately? It caught me off guard that this wasn't already figured out.
I should note that the strings I need to parse could be either of the two presented cases above.