tags:

views:

138

answers:

1

I am using the ruby gem "Chronic" to parse four digit strings as DateTime objects. I am using time in military format (ie: "0800") which seems from the documentaion to be a valid format.

In most cases, Chronic parses time in this format correctly - however it always parses a four digit string beginning with "12" as 00:XX AM of the next day, never as 12:XX PM of the current day.

For example:

>> Chronic.parse("1234")
=> Thu Sep 17 00:34:00 -0600 2009

I see that if I put a colon between the hours and minutes I get the desired output:

>> Chronic.parse("12:34")
=> Wed Sep 16 12:34:00 -0600 2009

I am however wanting to pass the value without a colon, like this:

>> Chronic.parse("1234")
=> Wed Sep 16 12:34:00 -0600 2009

What string do I have to pass to the parser in order for Chronic to interpret "1234" as 12:34 PM of the current day?

A: 

I'm not certain, but it looks like it might be a bug. My guess is you're ending up in this corner of the code:

http://github.com/mojombo/chronic/commit/c7d9591acf5179345cbc916bd509c48acee8e744

Steve Kass