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:31:32 UTC
svn commit: r1166327 - in /myfaces/trinidad/trunk:
src/site/xdoc/devguide/configuration.xml
trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java
trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
Author: gcrawford
Date: Wed Sep 7 19:31:32 2011
New Revision: 1166327
URL: http://svn.apache.org/viewvc?rev=1166327&view=rev
Log:
TRINIDAD-2133 Support Thai Buddhist calendar in client DateTimeConverter
Thanks to Yee-Wah Lee for patch
Modified:
myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java
myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
Modified: myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml?rev=1166327&r1=1166326&r2=1166327&view=diff
==============================================================================
--- myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml (original)
+++ myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml Wed Sep 7 19:31:32 2011
@@ -233,7 +233,7 @@ example, when the string is "1/1/11" and
DateTimeConverter will parse it into the Date equivalent to 1st January 1911.
If the property is not set, it is defaulted to year <code>1950</code>.
This property may be explicitly configured with an EL expression that returns
-Integer object or it can be directly harcoded to a integer value.
+Integer object or it 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/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java?rev=1166327&r1=1166326&r2=1166327&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DateBean.java Wed Sep 7 19:31:32 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/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=1166327&r1=1166326&r2=1166327&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 Wed Sep 7 19:31:32 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))