You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2012/03/03 00:41:44 UTC

svn commit: r1296514 - /myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js

Author: gcrawford
Date: Fri Mar  2 23:41:43 2012
New Revision: 1296514

URL: http://svn.apache.org/viewvc?rev=1296514&view=rev
Log:
TRINIDAD-2224 Client DateTimeConverter _fix2DYear does not handle th_TH locale

Modified:
    myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?rev=1296514&r1=1296513&r2=1296514&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js Fri Mar  2 23:41:43 2012
@@ -21,7 +21,7 @@
 //  _df2DYS: Sets the two-digit year start.
 
 var _AD_ERA = null;
-
+var _THAI_BUDDHIST_YEAR_OFFSET = 543;
 
 function _getADEra()
 {
@@ -354,7 +354,7 @@ function _subformat(
         
         // Trinidad-2013: Thai Buddhist Calendar is offset by 543 years
         if (locale == "th_TH")
-          year += 543;
+          year += _THAI_BUDDHIST_YEAR_OFFSET;
         
         // truncate 2 and 1 digit years to that number of digits
         var maxDigits = (charCount <= 2)
@@ -728,7 +728,7 @@ function _subparse(
           }
           else if ((charCount <= 2) && (year >= 0) && (year <= 100))
           {
-            year = _fix2DYear(year);
+            year = _fix2DYear(year, locale);
           }
 
           // There is no year "0"
@@ -737,7 +737,7 @@ function _subparse(
             
           // Trinidad-2013: Thai Buddhist Calendar is offset by 543 years
           if (locale == "th_TH")
-            year -= 543;
+            year -= _THAI_BUDDHIST_YEAR_OFFSET;
             
           parseContext.parsedFullYear = year;
         }
@@ -841,8 +841,9 @@ function _subparse(
 
 /**
  * Fix two-digit years.
+ * 
  */
-function _fix2DYear(year)
+function _fix2DYear(year, locale)
 {
   var defaultCentury;
 
@@ -854,6 +855,12 @@ function _fix2DYear(year)
     // year             1951  1901
     // year             1951  2001
     var offsetYear = _df2DYS;
+    
+    // Trinidad-2224: _fix2DYear should take into account the Thai Buddhist calendar.
+    // Here, two-digit-year-start is specified as a Gregorian year, so if the
+    // locale is Thai Buddhist, it needs to be translated into the Thai equivalent
+    if (locale == "th_TH")
+      offsetYear += _THAI_BUDDHIST_YEAR_OFFSET;
     defaultCentury = offsetYear - (offsetYear % 100);
 
     year += defaultCentury;
@@ -863,8 +870,14 @@ function _fix2DYear(year)
   else
   {
     var currentYear = new Date().getFullYear();
+
+    // Trinidad-2224: _fix2DYear should take into account the Thai Buddhist calendar. 
+    // Here, currentYear is a Gregorian Year, so it needs to be translated into the Thai equivalent
+    if (locale == "th_TH")
+      currentYear += _THAI_BUDDHIST_YEAR_OFFSET;
     defaultCentury = currentYear - (currentYear % 100) - 100;
 
+
     year += defaultCentury;
  
     // if the new year is now more than 80 years in the past,
@@ -876,6 +889,7 @@ function _fix2DYear(year)
     }
   }
 
+
   return year;
 }