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 2011/09/07 21:34:02 UTC

svn commit: r1166330 - in /myfaces/trinidad/branches/1.2.12.6.0-branch: src/site/xdoc/devguide/ trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/

Author: gcrawford
Date: Wed Sep  7 19:34:01 2011
New Revision: 1166330

URL: http://svn.apache.org/viewvc?rev=1166330&view=rev
Log:
TRINIDAD-2133 Support Thai Buddhist calendar in client DateTimeConverter

Thanks to Yee-Wah Lee for patch

Modified:
    myfaces/trinidad/branches/1.2.12.6.0-branch/src/site/xdoc/devguide/configuration.xml
    myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java
    myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js

Modified: myfaces/trinidad/branches/1.2.12.6.0-branch/src/site/xdoc/devguide/configuration.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.6.0-branch/src/site/xdoc/devguide/configuration.xml?rev=1166330&r1=1166329&r2=1166330&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.6.0-branch/src/site/xdoc/devguide/configuration.xml (original)
+++ myfaces/trinidad/branches/1.2.12.6.0-branch/src/site/xdoc/devguide/configuration.xml Wed Sep  7 19:34:01 2011
@@ -231,7 +231,8 @@ If it is not set, it is defaulted to yea
 used by <code>org.apache.myfaces.trinidad.converter.DateTimeConverter</code>
 while converting strings to Date. This property may also
 be explicitly configured with an EL expression that returns 
-Integer object if needed or can be directly harcoded to a integer value.
+Integer object if needed or can be directly harcoded to a integer value. This value should be  
+specified as a Gregorian Calendar year.
 </p>
         </subsection>
         <subsection name="right-to-left">

Modified: myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java?rev=1166330&r1=1166329&r2=1166330&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java (original)
+++ myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java Wed Sep  7 19:34:01 2011
@@ -135,7 +135,7 @@ public class DateBean implements java.io
   }
 
   public void setCurrentDate(Date date)
-  {
+  {    
     return;
   }
 
@@ -146,6 +146,7 @@ public class DateBean implements java.io
 
   public void setTodayFromMidnight(Date date)
   {
+    _todayFromMidnight = date;
     return;
   }
 
@@ -156,6 +157,7 @@ public class DateBean implements java.io
 
   public void setTonightNearMidnight(Date date)
   {
+    _tonightNearMidnight = date;
     return;
   }
 

Modified: myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?rev=1166330&r1=1166329&r2=1166330&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js (original)
+++ myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js Wed Sep  7 19:34:01 2011
@@ -69,6 +69,7 @@ function _isStrict(
 function _doClumping(
   formatPattern,
   localeSymbols,
+  locale,
   subFunction,
   param,
   outValue
@@ -108,6 +109,7 @@ function _doClumping(
         // output the quoted text
         if (!subFunction(formatPattern,
                          localeSymbols,
+                         locale,
                          "\'",
                          startIndex,
                          kindCount,
@@ -150,6 +152,7 @@ function _doClumping(
           // output the previously collected string
           if (!subFunction(formatPattern,
                            localeSymbols,
+                           locale,
                            lastChar,
                            startIndex,
                            kindCount,
@@ -184,6 +187,7 @@ function _doClumping(
   {
     if (!subFunction(formatPattern,
                      localeSymbols,
+                     locale,
                      lastChar,
                      startIndex,
                      kindCount,
@@ -207,6 +211,7 @@ function _doClumping(
 function _subformat(
   inString,
   localeSymbols,
+  locale,
   formatType,
   startIndex,
   charCount,
@@ -347,6 +352,10 @@ function _subformat(
       {
         var year = time.getFullYear();
         
+        // Trinidad-2013: Thai Buddhist Calendar is offset by 543 years
+        if (locale == "th_TH")
+          year += 543;
+        
         // truncate 2 and 1 digit years to that number of digits
         var maxDigits = (charCount <= 2)
                           ? charCount
@@ -470,6 +479,7 @@ function _getLocaleTimeZoneDifference()
 function _subparse(
   inString,      // the pattern string, such as "yyMMdd"
   localeSymbols,
+  locale,
   formatType,    // the current format char, such as 'y'
   startIndex,    // index into inString
   charCount,     // the number of chars of type formatType
@@ -733,7 +743,11 @@ function _subparse(
           // There is no year "0"
           if (year == 0)
             return false;
-
+            
+          // Trinidad-2013: Thai Buddhist Calendar is offset by 543 years
+          if (locale == "th_TH")
+            year -= 543;
+            
           parseContext.parsedFullYear = year;
         }
         else
@@ -1090,6 +1104,8 @@ function TrDateTimeConverter(
 
   // Stash away the patterns for later use.
   this._pattern = patterns;
+  
+  this._locale = (locale != null) ? locale : getJavaLanguage(locale);
 }
 
 TrDateTimeConverter.prototype = new TrConverter();
@@ -1134,6 +1150,7 @@ TrDateTimeConverter.prototype.getAsStrin
     
   _doClumping(pattern,
               this._localeSymbols,
+              this._locale,
               _subformat,
               formatTime,
               stringHolder);
@@ -1216,6 +1233,7 @@ TrDateTimeConverter.prototype.getAsObjec
     return this._simpleDateParseImpl(parseString,
                                 pattern,
                                 this._localeSymbols,
+                                this._locale,
                                 invalidFormatMsg,
                                 invalidDateMsg);
   }
@@ -1228,6 +1246,7 @@ TrDateTimeConverter.prototype.getAsObjec
         var date = this._simpleDateParseImpl(parseString,
                                         pattern[i],
                                         this._localeSymbols,
+                                        this._locale,
                                         invalidFormatMsg,
                                         invalidDateMsg);
         return date;
@@ -1368,6 +1387,7 @@ TrDateTimeConverter.prototype._simpleDat
   parseString,
   parsePattern,
   localeSymbols,
+  locale,
   invalidFormatMsg,
   invalidDateMsg)
 {
@@ -1401,6 +1421,7 @@ TrDateTimeConverter.prototype._simpleDat
   // parse the time
   if (_doClumping(parsePattern,
                   localeSymbols,
+                  locale,
                   _subparse,
                   parseContext,
                   parsedTime))