Changeset 8684
- Timestamp:
- 05/21/07 20:03:00 (18 months ago)
- Location:
- branches/0.4/src
- Files:
-
- 4 modified
-
date/format.js (modified) (6 diffs)
-
widget/DatePicker.js (modified) (4 diffs)
-
widget/DropdownDatePicker.js (modified) (2 diffs)
-
widget/templates/DatePicker.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/src/date/format.js
r6365 r8684 62 62 case 'G': 63 63 if(l>3){dojo.unimplemented("Era format not implemented");} 64 s = info.eras[dateObject.getFullYear() < 0 ? 1 : 0];64 s = bundle.eras[dateObject.getFullYear() < 0 ? 1 : 0]; 65 65 break; 66 66 case 'y': … … 70 70 break; 71 71 case 2: 72 s = String(s) .substr(-2);72 s = String(s); s = s.substr(s.length - 2); 73 73 break; 74 74 default: … … 103 103 var type = (c == "L") ? "standalone" : "format"; 104 104 var prop = ["months",type,width].join("-"); 105 s = info[prop][m];105 s = bundle[prop][m]; 106 106 } 107 107 break; … … 139 139 var type = (c == "c") ? "standalone" : "format"; 140 140 var prop = ["days",type,width].join("-"); 141 s = info[prop][d];141 s = bundle[prop][d]; 142 142 } 143 143 break; 144 144 case 'a': 145 145 var timePeriod = (dateObject.getHours() < 12) ? 'am' : 'pm'; 146 s = info[timePeriod];146 s = bundle[timePeriod]; 147 147 break; 148 148 case 'h': … … 203 203 case 'g': 204 204 case 'A': 205 dojo.debug(match+" modifier not yet implemented");205 // dojo.debug(match+" modifier not yet implemented"); 206 206 s = "?"; 207 207 break; … … 217 217 218 218 var locale = dojo.hostenv.normalizeLocale(options.locale); 219 var formatLength = options.formatLength || ' full';220 var info= dojo.date._getGregorianBundle(locale);219 var formatLength = options.formatLength || 'short'; 220 var bundle = dojo.date._getGregorianBundle(locale); 221 221 var str = []; 222 222 var sauce = dojo.lang.curry(this, formatPattern, dateObject); 223 if(options.selector == "yearOnly"){ 224 // Special case as this is not yet driven by CLDR data 225 var year = dateObject.getFullYear(); 226 if(locale.match(/^zh|^ja/)){ 227 year += "\u5E74"; 228 } 229 return year; 230 } 223 231 if(options.selector != "timeOnly"){ 224 var datePattern = options.datePattern || info["dateFormat-"+formatLength];232 var datePattern = options.datePattern || bundle["dateFormat-"+formatLength]; 225 233 if(datePattern){str.push(_processPattern(datePattern, sauce));} 226 234 } 227 235 if(options.selector != "dateOnly"){ 228 var timePattern = options.timePattern || info["timeFormat-"+formatLength];236 var timePattern = options.timePattern || bundle["timeFormat-"+formatLength]; 229 237 if(timePattern){str.push(_processPattern(timePattern, sauce));} 230 238 } -
branches/0.4/src/widget/DatePicker.js
r7305 r8684 109 109 fillInTemplate: function(args, frag) { 110 110 // summary: see dojo.widget.DomWidget 111 112 111 dojo.widget.DatePicker.superclass.fillInTemplate.apply(this, arguments); 113 114 112 // Copy style info from input node to output node 115 113 var source = this.getFragNodeRef(frag); … … 155 153 setDate: function(/*Date|String*/dateObj) { 156 154 //summary: set the current date and update the UI 157 if(dateObj == ""){ 158 this.value = ""; 159 this._preInitUI(this.curMonth,false,true); 160 }else if(typeof dateObj=="string"){ 161 this.value = dojo.date.fromRfc3339(dateObj); 155 var d = dateObj; 156 if(typeof(d)=="string" && d!=""){ 157 var t = dojo.date.fromRfc3339(d); 158 }else if(typeof(d)=="object"){ 159 var t = new Date(d); 160 }else{ 161 t = "" 162 } 163 if(typeof(t)=="object"){ 164 this.value = new Date(t); 162 165 this.value.setHours(0,0,0,0); 163 166 }else{ 164 this.value = new Date(dateObj);165 this.value.setHours(0,0,0,0);166 }167 this.value = ""; 168 } 169 167 170 if(this.selectedNode!=null){ 168 171 dojo.html.removeClass(this.selectedNode,this.classNames.selectedDate); 169 172 } 170 173 if(this.clickedNode!=null){ 171 dojo.debug('adding selectedDate');172 174 dojo.html.addClass(this.clickedNode,this.classNames.selectedDate); 173 175 this.selectedNode = this.clickedNode; 174 176 }else{ 175 177 //only call this if setDate was called by means other than clicking a date 176 this._preInitUI( this.value,false,true);178 this._preInitUI((this.value=="")?this.curMonth:this.value,false,true); 177 179 } 178 180 this.clickedNode=null; … … 190 192 //initFirst is to tell _initFirstDay if you want first day of the displayed calendar, or first day of the week for dateObj 191 193 //initUI tells preInitUI to go ahead and run initUI if set to true 192 if(typeof(this.startDate) == "string"){ 193 this.startDate = dojo.date.fromRfc3339(this.startDate); 194 } 195 if(typeof(this.endDate) == "string"){ 196 this.endDate = dojo.date.fromRfc3339(this.endDate); 197 } 194 function checkDate(d , s){ 195 if(typeof(d)=="string"){ 196 var t = dojo.date.fromRfc3339(d); 197 if(t==null && typeof(s)=="string"){ 198 var t = dojo.date.fromRfc3339(s); 199 } 200 return t; 201 } 202 return d; 203 } 204 this.startDate = checkDate(this.startDate, "1492-10-12"); 205 this.endDate = checkDate(this.endDate, "2941-10-12"); 206 198 207 this.startDate.setHours(0,0,0,0); //adjust startDate to be exactly midnight 199 208 this.endDate.setHours(24,0,0,-1); //adjusting endDate to be a fraction of a second before midnight … … 415 424 function f(n){ 416 425 that[n+"YearLabelNode"].innerHTML = 417 dojo.date.format(new Date(y++, 0), { formatLength:'yearOnly', locale:that.lang});426 dojo.date.format(new Date(y++, 0), {selector:'yearOnly', locale:that.lang}); 418 427 } 419 428 f("previous"); -
branches/0.4/src/widget/DropdownDatePicker.js
r7305 r8684 102 102 if(typeof(this.value)=='string'&&this.value.toLowerCase()=='today'){ 103 103 this.value = new Date(); 104 } 105 if(this.value && isNaN(this.value)){ 104 }else if(this.value && isNaN(this.value)){ 106 105 var orig = this.value; 107 106 this.value = dojo.date.fromRfc3339(this.value); 108 if(!this.value){this.value = new Date(orig); dojo.deprecated("dojo.widget.DropdownDatePicker", "date attributes must be passed in Rfc3339 format", "0.5");} 109 } 110 if(this.value && !isNaN(this.value)){ 107 }else if(this.value && !isNaN(this.value)){ 111 108 this.value = new Date(this.value); 112 109 } … … 160 157 {formatLength:this.formatLength, datePattern:this.displayFormat, selector:'dateOnly', locale:this.lang}) : 161 158 ""; 162 163 if(this.value < this.datePicker.startDate||this.value>this.datePicker.endDate){ 159 if(this.datePicker.value < this.datePicker.startDate||this.value>this.datePicker.endDate){ 164 160 this.inputNode.value = ""; 165 161 } -
branches/0.4/src/widget/templates/DatePicker.html
r7305 r8684 93 93 </tfoot> 94 94 </table> 95 95 96 </div>