mojombo / chronic

Chronic is a pure Ruby natural language date parser.
http://injekt.github.com/chronic
MIT License
3.24k stars 458 forks source link

Parsing hour < 6 gets converted to PM #314

Open WizardOfOgz opened 8 years ago

WizardOfOgz commented 8 years ago

When parsing datetimes the hour is handled inconsistently when no meridiem value is given. The result is as expected for cases in which the hour is 6 or greater (without a leading 0). E.g. "6:00" is correctly parsed as 6:00 AM. For cases where the hour is less than 6 (without a leading 0) then the time is converted to PM, e.g. "5:00" is incorrectly parsed as 5:00 PM.

Note that 2-digit (0-padded) values are handled correctly.

Examples

> Chronic.parse("2015-10-20 6:00")   # Works
 => 2015-10-20 06:00:00 -1100
> Chronic.parse("2015-10-20 5:00")   # Fails
 => 2015-10-20 17:00:00 -1100
> Chronic.parse("2015-10-20 05:00")  # Works
 => 2015-10-20 05:00:00 -1100

Affected Chronic versions:

Tested with various system time zone settings (OSX 10.11), within a Rails (4.2.4) environment with and without a configured time zone, and in IRB (non-Rails environment).

WizardOfOgz commented 8 years ago

@kylejginavan anything else?