Changeset 7542
- Timestamp:
- 03/06/07 20:24:40 (22 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
src/widget/DatePicker.js (modified) (4 diffs)
-
src/widget/DropdownDatePicker.js (modified) (2 diffs)
-
tests/widget/test_DropdownDatePicker.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/widget/DatePicker.js
r7382 r7542 1 dojo.provide("dojo.widget.DatePicker");1 dojo.provide("dojo.widget.DatePicker"); 2 2 dojo.require("dojo.date.common"); 3 3 dojo.require("dojo.date.format"); … … 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 -
trunk/src/widget/DropdownDatePicker.js
r7178 r7542 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 } -
trunk/tests/widget/test_DropdownDatePicker.html
r7138 r7542 66 66 <p>With initial date of 1969-04-25 and a custom format dd/MM/yyyy</p> 67 67 <input name="dddp5" dojoType="dropdowndatepicker" inputName="mydate1" value="1969-04-25" displayFormat="dd/MM/yyyy" /> 68 \<p>In German:</p>68 <p>In German:</p> 69 69 <input name="dddp7" dojoType="dropdowndatepicker" value="2006-06-28" lang="de" /> 70 70 <p>In Dutch:</p> … … 91 91 </div> 92 92 <br /> 93 These are broken tests for trac tickets:<br/> 94 Wipe: with startDate="2006-10-10" (inputNode is not updating when clicking a date ticket #1694) 93 Wipe: with startDate="2006-10-10" 95 94 <input dojoType="dropdowndatepicker" startDate="2006-10-10" containerToggle="wipe" containerToggleDuration="300"> 96 95 <br /> 97 Explode: testing invalid initial value of "oiwerwerw" (should render as no value provided not NaN/NaN/NaN ticket #1692)96 Explode: testing invalid initial value of "oiwerwerw" 98 97 <input dojoType="dropdowndatepicker" value="oiwerwerw" containerToggle="explode" containerToggleDuration="500"> 99 98 <br /><br />