Updated Branches: refs/heads/develop ec1ac280b -> 55b14753e
FLEX-33516 fixed parsing dates so that it support DD/MM/YYYY format in non eu_US locales Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/0ca90020 Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/0ca90020 Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/0ca90020 Branch: refs/heads/develop Commit: 0ca900201017848ae1d3a05679604d47e1417e7c Parents: 9084f81 Author: Justin Mclean <jmcl...@apache.org> Authored: Sun Apr 28 18:13:06 2013 +1000 Committer: Justin Mclean <jmcl...@apache.org> Committed: Sun Apr 28 18:13:06 2013 +1000 ---------------------------------------------------------------------- .../framework/src/mx/formatters/DateFormatter.as | 19 +++++++++++---- 1 files changed, 14 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/0ca90020/frameworks/projects/framework/src/mx/formatters/DateFormatter.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/src/mx/formatters/DateFormatter.as b/frameworks/projects/framework/src/mx/formatters/DateFormatter.as index b82b2b1..5c3d8c7 100644 --- a/frameworks/projects/framework/src/mx/formatters/DateFormatter.as +++ b/frameworks/projects/framework/src/mx/formatters/DateFormatter.as @@ -106,6 +106,10 @@ public class DateFormatter extends Formatter * * <pre> * var myDate:Date = DateFormatter.parseDateString("2009-12-02 23:45:30"); </pre> + * + * The optional format property is use to work out which is likly to be encountered + * first a month or a date of the month for date where it may not be obvious which + * comes first. * * @see mx.formatters.DateBase * @@ -118,7 +122,7 @@ public class DateFormatter extends Formatter * @playerversion AIR 1.1 * @productversion Flex 3 */ - public static function parseDateString (str:String):Date + public static function parseDateString (str:String, format:String = null):Date { if (!str || str == "") return null; @@ -297,12 +301,17 @@ public class DateFormatter extends Formatter // assign num to year or month or day or sec. else if (punctuation.hasOwnProperty(letter) && punctuation[letter].date) { - // FIXME assumes month come before day ie US style - // dates MM/DD/YYYY or year first dates YYYY/MM/DD - if (mon < 0) + var monthFirst:Boolean = year != -1; + + if (format) + monthFirst = monthFirst || format.search("M") < format.search("D"); + + if (monthFirst && mon < 0) mon = (num - 1); else if (day < 0) day = num; + else if (!monthFirst && mon < 0) + mon = (num -1); else if (sec < 0) sec = num; else if (milli < 0) @@ -670,7 +679,7 @@ public class DateFormatter extends Formatter if (value is String) { - value = DateFormatter.parseDateString(String(value)); + value = DateFormatter.parseDateString(String(value), formatString); if (!value) { error = defaultInvalidValueError;