2 Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo._hasResource["dojox.date.posix"]){
9 dojo._hasResource["dojox.date.posix"]=true;
10 dojo.provide("dojox.date.posix");
11 dojo.require("dojo.date");
12 dojo.require("dojo.date.locale");
13 dojo.require("dojo.string");
14 dojox.date.posix.strftime=function(_1,_2,_3){
17 return dojo.string.pad(s,n||2,_4||"0");
19 var _8=dojo.date.locale._getGregorianBundle(_3);
23 return dojo.date.locale.getNames("days","abbr","format",_3)[_1.getDay()];
25 return dojo.date.locale.getNames("days","wide","format",_3)[_1.getDay()];
28 return dojo.date.locale.getNames("months","abbr","format",_3)[_1.getMonth()];
30 return dojo.date.locale.getNames("months","wide","format",_3)[_1.getMonth()];
32 return dojo.date.locale.format(_1,{formatLength:"full",locale:_3});
34 return _(Math.floor(_1.getFullYear()/100));
36 return _(_1.getDate());
38 return $("m")+"/"+$("d")+"/"+$("y");
43 return _(_1.getDate());
48 return _(_1.getMonth()+1);
52 dojo.unimplemented("unimplemented modifier 'G'");
55 return $("Y")+"-"+$("m")+"-"+$("d");
57 return _(_1.getHours());
59 return _(_1.getHours()%12||12);
61 return _(dojo.date.locale._getDayOfYear(_1),3);
66 return _(_1.getHours());
71 return _(_1.getHours()%12||12);
73 return _(_1.getMonth()+1);
75 return _(_1.getMinutes());
79 return _8[_1.getHours()<12?"am":"pm"];
81 return $("I")+":"+$("M")+":"+$("S")+" "+$("p");
83 return $("H")+":"+$("M");
85 return _(_1.getSeconds());
89 return $("H")+":"+$("M")+":"+$("S");
91 return String(_1.getDay()||7);
93 return _(dojo.date.locale._getWeekOfYear(_1));
95 return _(dojox.date.posix.getIsoWeekOfYear(_1));
97 return _(dojo.date.locale._getWeekOfYear(_1,1));
99 return String(_1.getDay());
101 return dojo.date.locale.format(_1,{selector:"date",formatLength:"full",locale:_3});
103 return dojo.date.locale.format(_1,{selector:"time",formatLength:"full",locale:_3});
105 return _(_1.getFullYear()%100);
107 return String(_1.getFullYear());
109 var _b=_1.getTimezoneOffset();
110 return (_b>0?"-":"+")+_(Math.floor(Math.abs(_b)/60))+":"+_(Math.abs(_b)%60);
112 return dojo.date.getTimezoneName(_1);
121 while((_e=_2.indexOf("%",i))!=-1){
122 _c+=_2.substring(i,_e++);
123 switch(_2.charAt(_e++)){
147 var _10=$(_2.charAt(_e++));
150 _10=_10.toUpperCase();
153 _10=_10.toLowerCase();
156 var _11=_10.toLowerCase();
159 for(var j=0;j<_10.length;j++){
161 _12+=(ch==_11.charAt(j))?ch.toUpperCase():ch.toLowerCase();
175 dojox.date.posix.getStartOfWeek=function(_15,_16){
177 _16=dojo.cldr.supplemental.getFirstDayOfWeek?dojo.cldr.supplemental.getFirstDayOfWeek():0;
180 if(_15.getDay()>=_16){
183 _17-=(7-_15.getDay());
185 var _18=new Date(_15);
186 _18.setHours(0,0,0,0);
187 return dojo.date.add(_18,"day",_17);
189 dojox.date.posix.setIsoWeekOfYear=function(_19,_1a){
193 var _1b=dojox.date.posix.getIsoWeekOfYear(_19);
196 var _1d=dojox.date.posix.getIsoWeeksInYear(_19);
199 return dojo.date.add(_19,"week",_1c);
201 dojox.date.posix.getIsoWeekOfYear=function(_1e){
202 var _1f=dojox.date.posix.getStartOfWeek(_1e,1);
203 var _20=new Date(_1e.getFullYear(),0,4);
204 _20=dojox.date.posix.getStartOfWeek(_20,1);
205 var _21=_1f.getTime()-_20.getTime();
207 return dojox.date.posix.getIsoWeeksInYear(_1f);
209 return Math.ceil(_21/604800000)+1;
211 dojox.date.posix.getIsoWeeksInYear=function(_22){
213 return y+Math.floor(y/4)-Math.floor(y/100)+Math.floor(y/400);
215 var y=_22.getFullYear();
216 return (p(y)%7==4||p(y-1)%7==3)?53:52;