META-INF.adf.jsLibs.DateFormat.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trinidad-impl Show documentation
Show all versions of trinidad-impl Show documentation
Private implementation of the Apache MyFaces Trinidad project
The newest version!
var _AD_ERA=null;
function _getADEra()
{
if(_AD_ERA==null)
{
_AD_ERA=new Date(0);
_AD_ERA.setFullYear(1);
}
return _AD_ERA;
}
function _isStrict(
a0,
a1)
{
var a2=["FullYear","Month","Date","Hours","Minutes",
"Seconds","Milliseconds"];
for(var a3=0;a3='A')&&(a3<='Z')||
(a3>='a')&&(a3<='z'))
{
switch(a3)
{
case'D':
a8="(Day in Year)";
break;
case'E':
{
var a10=a6.getDay();
a8=(a5<=3)
?a1.getShortWeekdays()[a10]
:a1.getWeekdays()[a10];
}
break;
case'F':
a8="(Day of week in month)";
break;
case'G':
{
var a11=a1.getEras();
a8=(a6.getTime()<_getADEra().getTime())
?a11[0]
:a11[1];
}
break;
case'M':
{
var a12=a6.getMonth();
if(a5<=2)
{
a8=_getPaddedNumber(a12+1,a5);
}
else if(a5==3)
{
a8=a1.getShortMonths()[a12];
}
else
{
a8=a1.getMonths()[a12];
}
}
break;
case'S':
a8=_getPaddedNumber(a6.getMilliseconds(),a5);
break;
case'W':
a8="(Week in Month)";
break;
case'a':
{
var a13=a1.getAmPmStrings();
a8=(_isPM(a6.getHours()))
?a13[1]
:a13[0];
}
break;
case'd':
a8=_getPaddedNumber(a6.getDate(),a5);
break;
case'h':
hours=a6.getHours();
if(_isPM(hours))
hours-=12;
if(hours==0)
hours=12;
a8=_getPaddedNumber(hours,a5);
break;
case'K':
hours=a6.getHours();
if(_isPM(hours))
hours-=12;
a8=_getPaddedNumber(hours,a5);
break;
case'k':
hours=a6.getHours();
if(hours==0)
hours=24;
a8=_getPaddedNumber(hours,a5);
break;
case'H':
a8=_getPaddedNumber(a6.getHours(),a5);
break;
case'm':
a8=_getPaddedNumber(a6.getMinutes(),a5);
break;
case's':
a8=_getPaddedNumber(a6.getSeconds(),a5);
break;
case'w':
a8="(Week in year)";
break;
case'y':
{
var a14=a6.getFullYear();
if(a2=="th_TH")
a14+=543;
var a15=(a5<=2)
?a5
:null;
a8=_getPaddedNumber(a14,a5,a15);
}
break;
case'z':
{
a8="GMT";
var a16=_getTimeZoneOffsetString(a6,false);
if(a16)
{
a8+=a16[0];
a8+=":"
a8+=a16[1];
}
}
break;
case'Z':
{
var a16=_getTimeZoneOffsetString(a6,true);
if(a16)
{
a8=a16[0];
a8+=a16[1];
}
else
{
a8="";
}
}
break;
default:
a8="";
}
}
else
{
a8=a0.substring(a4,a4+a5);
}
a7.value+=a8;
return true;
}
function _getTimeZoneOffsetString(a0,a1)
{
var a2=-1*a0.getTimezoneOffset();
a2+=_getLocaleTimeZoneDifference();
if(a1||a2!=0)
{
var a3=new Array(2);
if(a2<0)
{
a3[0]="-";
a2=-a2
}
else
{
a3[0]="+";
}
a3[0]+=_getPaddedNumber(Math.floor(a2/60),2);
a3[1]=_getPaddedNumber(a2%60,2);
return a3;
}
}
function _getLocaleTimeZoneDifference()
{
var a0=new Date();
var a1=a0.getTimezoneOffset()*-1;
var a2=0;
return a2-a1;
}
function _subparse(
a0,
a1,
a2,
a3,
a4,
a5,
a6,
a7
)
{
var a8=a6.currIndex;
var a9=(a4+a5='A')&&(a3<='Z')||
(a3>='a')&&(a3<='z'))
{
switch(a3)
{
case'D':
if(_accumulateNumber(a6,!a10?3:a5)==null)
{
return false;
}
break;
case'E':
{
var a11=_matchArray(a6,
(a5<=3)
?a1.getShortWeekdays()
:a1.getWeekdays());
if(a11==null)
{
return false;
}
}
break;
case'F':
if(_accumulateNumber(a6,!a10?2:a5)==null)
{
return false;
}
break;
case'G':
{
var a12=_matchArray(a6,a1.getEras());
if(a12!=null)
{
if(a12==0)
{
a6.parsedBC=true;
}
}
else
{
return false;
}
}
break;
case'M':
{
var a13;
var a14=0;
if(a5<=2)
{
a13=_accumulateNumber(a6,!a10?2:a5);
a14=-1;
}
else
{
var a15=(a5==3)
?a1.getShortMonths()
:a1.getMonths();
a13=_matchArray(a6,a15);
}
if(a13!=null)
{
a6.parsedMonth=(a13+a14);
}
else
{
return false;
}
}
break;
case'S':
{
var a16=_accumulateNumber(a6,!a10?3:a5);
if(a16!=null)
{
a6.parsedMilliseconds=a16;
}
else
{
return false;
}
}
break;
case'W':
if(_accumulateNumber(a6,!a10?2:a5)==null)
{
return false;
}
break;
case'a':
{
var a17=_matchArray(a6,
a1.getAmPmStrings());
if(a17==null)
{
return false;
}
else
{
if(a17==1)
{
a6.isPM=true;
}
}
}
break;
case'd':
{
var a18=_accumulateNumber(a6,!a10?2:a5);
if(a18!=null)
{
a6.parsedDate=a18;
}
else
{
return false;
}
}
break;
case'h':
case'k':
case'H':
case'K':
{
var a19=_accumulateNumber(a6,!a10?2:a5);
if(a19!=null)
{
if((a3=='h')&&(a19==12))
a19=0;
if((a3=='k')&&(a19==24))
a19=0;
a6.parsedHour=a19;
}
else
{
return false;
}
}
break;
case'm':
{
var a20=_accumulateNumber(a6,!a10?2:a5);
if(a20!=null)
{
a6.parsedMinutes=a20;
}
else
{
return false;
}
}
break;
case's':
{
var a21=_accumulateNumber(a6,!a10?2:a5);
if(a21!=null)
{
a6.parsedSeconds=a21;
}
else
{
return false;
}
}
break;
case'w':
if(_accumulateNumber(a6,!a10?2:a5)==null)
{
return false;
}
break;
case'y':
{
var a22=_accumulateNumber(a6,!a10?4:a5);
var a23=a6.currIndex-a8;
if(a22!=null)
{
if((a23>2)&&
(a5<=2)&&
(a22<=999))
{
return false;
}
else if((a5<=2)&&(a22>=0)&&(a22<=100))
{
a22=_fix2DYear(a22);
}
else if(a5==4)
{
if(a23==3)
return false;
if(a23<=2)
a22=_fix2DYear(a22);
}
if(a22==0)
return false;
if(a2=="th_TH")
a22-=543;
a6.parsedFullYear=a22;
}
else
{
return false;
}
}
break;
case'z':
{
if(!_matchText(a6,"GMT"))
{
return false;
}
if((a6.parseString.length-a6.currIndex)>0)
{
if(_matchArray(a6,["-","+"])==null)
{
return false;
}
var a24=_accumulateNumber(a6,2);
if(a24==null)
{
return false;
}
a6.hourOffset=a24;
if(!_matchText(a6,":"))
{
return false;
}
var a25;
if(((a6.parseString.length-a6.currIndex)<2)||
(a25=_accumulateNumber(a6,2))==null)
{
return false;
}
a6.minOffset=a25;
}
}
break;
case'Z':
{
if((a6.parseString.length-a6.currIndex)<5)
{
return false;
}
if(_matchArray(a6,["-","+"])==null)
{
return false;
}
var a24=_accumulateNumber(a6,2)
if(a24==null)
{
return false;
}
a6.hourOffset=a24;
var a25=_accumulateNumber(a6,2)
if(a25==null)
{
return false;
}
a6.minOffset=null;
}
break;
default:
}
}
else
{
return _matchText(a6,
a0.substring(a4,a4+a5));
}
return true;
}
function _fix2DYear(a0)
{
var a1;
if(_df2DYS!=null)
{
var a2=_df2DYS;
a1=a2-(a2%100);
a0+=a1;
if(a0a4.length-a3)
{
return false;
}
var a5=a4.substring(a3,a3+a2);
var a6=a5.toLowerCase();
var a7=a1.toLowerCase();
if(a6!=a7)
return false;
a0.currIndex+=a2;
return true;
}
function _accumulateNumber(
a0,
a1
)
{
var a2=a0.currIndex;
var a3=a2;
var a4=a0.parseString;
var a5=a4.length;
if(a5>a3+a1)
a5=a3+a1;
var a6=0;
while(a3=12);
}
function _getPaddedNumber(
a0,
a1,
a2
)
{
var a3=a0.toString();
if(a1!=null)
{
var a4=a1-a3.length;
while(a4>0)
{
a3="0"+a3;
a4--;
}
}
if(a2!=null)
{
var a5=a3.length-a2;
if(a5>0)
{
a3=a3.substring(a5,
a5+a2);
}
}
return a3;
}
var _CONVENIENCE_PATTERNS=null;
function TrDateTimeConverter(
a0,
a1,
a2,
a3,
a4
)
{
this._class="TrDateTimeConverter";
this._exampleString=a2;
this._type=a3;
this._messages=a4;
this._offset=null;
this._localeSymbols=getLocaleSymbols(a1);
if(a0==null)
a0=this._localeSymbols.getShortDatePatternString();
var a5=this._initPatterns(a0,a1);
this._pattern=a5;
this._locale=(a1!=null)?a1:getJavaLanguage(a1);
}
TrDateTimeConverter.prototype=new TrConverter();
TrDateTimeConverter.prototype.getFormatHint=function()
{
if(this._messages&&this._messages["hint"])
{
return TrMessageFactory.createCustomMessage(
this._messages["hint"],
""+this._exampleString);
}
else
{
var a6="org.apache.myfaces.trinidad.convert.DateTimeConverter."+this._type+"_HINT";
return TrMessageFactory.createMessage(
a6,
""+this._exampleString);
}
}
TrDateTimeConverter.prototype.getAsString=function(
a7
)
{
if(this._offset)
{
var a8=a7.getMinutes();
a7.setMinutes((+a8)-parseInt(this._offset));
}
var a9=new Object();
a9.value="";
var a10=this._pattern;
if(typeof a10!="string")
a10=a10[0];
_doClumping(a10,
this._localeSymbols,
this._locale,
_subformat,
a7,
a9);
if(this._offset)
{
var a11=(((this._offset+a7.getTimezoneOffset())*-1)/60);
if(parseInt(a11)>0)
{
a9.value=a9.value+"+"
}
a9.value=a9.value+a11+":00";
}
return a9.value;
}
TrDateTimeConverter.prototype.setDiffInMins=function(
a12
)
{
this._offset=a12;
}
TrDateTimeConverter.prototype.getDiffInMins=function()
{
return this._offset;
}
TrDateTimeConverter.prototype.getLocaleSymbols=function()
{
return this._localeSymbols;
}
TrDateTimeConverter.prototype.getAsObject=function(
a13,
a14
)
{
if(a13==null)
return null;
a13=TrFormatUtils.trim(a13);
if(a13.length==0)
return null;
var a15=this._pattern;
var a16;
var a17="org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_"+this._type;
if(this._messages&&this._messages["detail"])
{
a16=_createCustomFacesMessage(TrMessageFactory.getSummaryString(a17),
this._messages["detail"],
a14,
a13,
this._exampleString);
}
else
{
a16=_createFacesMessage(a17,
a14,
a13,
this._exampleString);
}
var a18=_createFacesMessage("org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_DATE_INVALID_DATE",
a14,
a13);
if(typeof a15=="string")
{
return this._simpleDateParseImpl(a13,
a15,
this._localeSymbols,
this._locale,
a16,
a18);
}
else
{
var a19;
for(a19=0;a19