globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

Parsing time not adjusting for pm. #740

Closed jsearles closed 7 years ago

jsearles commented 7 years ago

I am attempting to parse a PM time using "en-US" as the locale. The value i'm attempting to parse is "2:12:34 pm". I am using a skeleton of "jms". The time parses, but does not adjust the 12 hours for PM. When i step through the code, this is the portion that looks like it should be accounting for PM:

    if ( hour12 && amPm === "pm" ) {
        date.setHours( date.getHours() + 12 );
    }

However "amPm" is equal to "pm-alt-variant" at this point, so the time is not adjusted.

I am using version "1.3.0-rc.0".

jrsearles commented 7 years ago

OK, doing some more debugging i've determined this is caused by the fact that the "pm" indicator is lower case in the string. This is matching with "pm-alt-variant" in CLDR. Globalize should likely be checking for this value in the above block as well.

rxaviers commented 7 years ago

Closing in favor of #544 (PR #546)