flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcl...@apache.org
Subject [2/4] git commit: [flex-sdk] - FLEX-33514 fixed am/pm issue with other locales
Date Wed, 24 Apr 2013 03:41:19 GMT
FLEX-33514 fixed am/pm issue with other 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/27b44212
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/27b44212
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/27b44212

Branch: refs/heads/develop
Commit: 27b4421209a906ac6f64a81d948f1917b853d3c8
Parents: faee10e
Author: Justin Mclean <jmclean@apache.org>
Authored: Wed Apr 24 13:38:42 2013 +1000
Committer: Justin Mclean <jmclean@apache.org>
Committed: Wed Apr 24 13:38:42 2013 +1000

----------------------------------------------------------------------
 .../framework/src/mx/formatters/DateFormatter.as   |   32 ++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/27b44212/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 d3c585f..b82b2b1 100644
--- a/frameworks/projects/framework/src/mx/formatters/DateFormatter.as
+++ b/frameworks/projects/framework/src/mx/formatters/DateFormatter.as
@@ -136,8 +136,10 @@ public class DateFormatter extends Formatter
         
         var count:int = 0;
         var len:int = str.length;
+		var isPM:Boolean = false;
 		
 		var punctuation:Object = {};
+		var ampm:Object = {};
 			
 		punctuation["/"] = {general:true, date:true, time:false};
 		punctuation[":"] = {general:true, date:false, time:true};
@@ -151,12 +153,19 @@ public class DateFormatter extends Formatter
 		punctuation["月"] = {general:true, date:true, time:false};
 		punctuation["日"] = {general:true, date:true, time:false};
 		punctuation["午"] = {general:false, date:false, time:true};
-		
 		// Korean
 		punctuation["년"] = {general:true, date:true, time:false};
 		punctuation["월"] = {general:true, date:true, time:false};
 		punctuation["일"] = {general:true, date:true, time:false};
 		
+		ampm["PM"] = true;
+		ampm["pm"] = true;
+		ampm["\u33D8"] = true; // unicode pm
+		ampm["μμ"] = true; // Greek
+		ampm["午後"] = true; // Japanese
+		ampm["上午"] = true; // Chinese
+		ampm["오후"] = true; // Korean
+		
         // Strip out the Timezone. It is not used by the DateFormatter
         var timezoneRegEx:RegExp = /(GMT|UTC)((\+|-)\d\d\d\d )?/ig;
         
@@ -237,6 +246,17 @@ public class DateFormatter extends Formatter
                     }
                 }
                 marker = 0;
+				
+				// Other lacales AM/PM 
+				if (ampm.hasOwnProperty(word))
+				{
+					isPM = true;
+					
+					if (hour > 12)
+						break; // error
+					else if (hour >= 0)
+						hour += 12;
+				}
             }
             
             else if ("0" <= letter && letter <= "9")
@@ -296,7 +316,17 @@ public class DateFormatter extends Formatter
                 else if (punctuation.hasOwnProperty(letter) && punctuation[letter].time)
                 {
                     if (hour < 0)
+					{
                         hour = num;
+						
+						if (isPM)
+						{
+							if (hour > 12)
+								break; //error
+							else
+								hour += 12;
+						}
+					}
                     else if (min < 0)
                         min = num;
 					else if (sec < 0)


Mime
View raw message