You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flex.apache.org by "Justin Mclean (JIRA)" <ji...@apache.org> on 2014/04/03 00:47:19 UTC
[jira] [Commented] (FLEX-34209) DateFormatter's parseDateTime
method doesn't handle AM PM properly when time is in the 12 PM hour
[ https://issues.apache.org/jira/browse/FLEX-34209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13958283#comment-13958283 ]
Justin Mclean commented on FLEX-34209:
--------------------------------------
ampm.howOwnProperty checks for various pm strings.
Form the top of the method.
ampm["PM"] = true;
ampm["pm"] = true;
ampm["\u33D8"] = true; // unicode pm
ampm["μμ"] = true; // Greek
ampm["午後"] = true; // Japanese
ampm["上午"] = true; // Chinese
ampm["오후"] = true; // Korean
Looks like something odd may be going will check into it.
Thanks for reporting.
> DateFormatter's parseDateTime method doesn't handle AM PM properly when time is in the 12 PM hour
> -------------------------------------------------------------------------------------------------
>
> Key: FLEX-34209
> URL: https://issues.apache.org/jira/browse/FLEX-34209
> Project: Apache Flex
> Issue Type: Bug
> Affects Versions: Apache Flex 4.12.0
> Reporter: Doug Pierce
> Assignee: Justin Mclean
>
> DateFormatter.parseDateTime does not properly parse strings in the noon hour with an AM or PM designator.
> For example, "2/13/2014 12:23:22 PM" does not translate to a date and instead returns a null value.
> Upon research into this method, it appears that there is a secondary "catch all" conditional for "Other Locales AM PM" that actually overwrites correct derivation of the "hour" value that is used to create the return Date value:
> // Other lacales AM/PM
> if (ampm.hasOwnProperty(word))
> {
> isPM = true;
>
> if (hour > 12)
> break; // error
> else if (hour >= 0)
> hour += 12;
> }
> This conditional does not appear to handle any time between 12:00, including, and 1:00 PM, excluding, properly as it makes the hour 24. When the final return value is calculated, the 24 hour actually rounds the total date value UP to the next day, resulting in a failed date derivation validation check found near the bottom of this method:
> // create a date object and check the validity of the input date
> // by comparing the result with input values.
> var newDate:Date = new Date(year, mon, day, hour, min, sec, milli);
> if (day != newDate.getDate() || mon != newDate.getMonth())
> return null;
> The check compares the read "day" value against the derived "getDate()" value which proves a true value - returning null instead of the derived date.
> I'm unsure of the reasoning for the "other locales" conditional. Therefore simply removing it may not be the proper solution. A better solution may be to remove the 12 value from the conditional as so:
>
> // Other lacales AM/PM
> if (ampm.hasOwnProperty(word))
> {
> isPM = true;
>
> if (hour > 12)
> break; // error
> else if (hour >= 0 && hour < 12)
> hour += 12;
> }
--
This message was sent by Atlassian JIRA
(v6.2#6252)