Changeset 7542

Show
Ignore:
Timestamp:
03/06/07 20:24:40 (22 months ago)
Author:
ktiedt
Message:

Fixes #1694 Fixes #1692
Finally found and fixed these 2 bugs... Test case updated to remove the "known bug" test case text.

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/widget/DatePicker.js

    r7382 r7542  
    1 dojo.provide("dojo.widget.DatePicker"); 
     1        dojo.provide("dojo.widget.DatePicker"); 
    22dojo.require("dojo.date.common"); 
    33dojo.require("dojo.date.format"); 
     
    109109                fillInTemplate: function(args, frag) { 
    110110                        // summary: see dojo.widget.DomWidget 
    111  
    112111                        dojo.widget.DatePicker.superclass.fillInTemplate.apply(this, arguments); 
    113  
    114112                        // Copy style info from input node to output node 
    115113                        var source = this.getFragNodeRef(frag); 
     
    155153                setDate: function(/*Date|String*/dateObj) { 
    156154                        //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); 
    162165                                this.value.setHours(0,0,0,0); 
    163166                        }else{ 
    164                                 this.value = new Date(dateObj); 
    165                                 this.value.setHours(0,0,0,0); 
    166                         } 
     167                                this.value = ""; 
     168                        } 
     169                 
    167170                        if(this.selectedNode!=null){ 
    168171                                dojo.html.removeClass(this.selectedNode,this.classNames.selectedDate); 
    169172                        } 
    170173                        if(this.clickedNode!=null){ 
    171                                 dojo.debug('adding selectedDate'); 
    172174                                dojo.html.addClass(this.clickedNode,this.classNames.selectedDate); 
    173175                                this.selectedNode = this.clickedNode; 
    174176                        }else{ 
    175177                                //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); 
    177179                        } 
    178180                        this.clickedNode=null; 
     
    190192                        //initFirst is to tell _initFirstDay if you want first day of the displayed calendar, or first day of the week for dateObj 
    191193                        //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 
    198207                        this.startDate.setHours(0,0,0,0); //adjust startDate to be exactly midnight 
    199208                        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  
    102102                        if(typeof(this.value)=='string'&&this.value.toLowerCase()=='today'){ 
    103103                                this.value = new Date(); 
    104                         } 
    105                         if(this.value && isNaN(this.value)){ 
     104                        }else if(this.value && isNaN(this.value)){ 
    106105                                var orig = this.value; 
    107106                                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)){ 
    111108                                this.value = new Date(this.value); 
    112109                        } 
     
    160157                                        {formatLength:this.formatLength, datePattern:this.displayFormat, selector:'dateOnly', locale:this.lang}) : 
    161158                                ""; 
    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){ 
    164160                                this.inputNode.value = ""; 
    165161                        } 
  • trunk/tests/widget/test_DropdownDatePicker.html

    r7138 r7542  
    6666                        <p>With initial date of 1969-04-25 and a custom format dd/MM/yyyy</p> 
    6767                                <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> 
    6969                                <input name="dddp7" dojoType="dropdowndatepicker" value="2006-06-28" lang="de" /> 
    7070                        <p>In Dutch:</p> 
     
    9191        </div>   
    9292    <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" 
    9594        <input dojoType="dropdowndatepicker" startDate="2006-10-10" containerToggle="wipe" containerToggleDuration="300"> 
    9695        <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" 
    9897        <input dojoType="dropdowndatepicker" value="oiwerwerw" containerToggle="explode" containerToggleDuration="500"> 
    9998        <br /><br />