Changeset 8684

Show
Ignore:
Timestamp:
05/21/07 20:03:00 (18 months ago)
Author:
ktiedt
Message:

fixes #2665
fixes #2674
This fixes 2 very annoying bugs and cleans up a few things.

Location:
branches/0.4/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/0.4/src/date/format.js

    r6365 r8684  
    6262                                case 'G': 
    6363                                        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]; 
    6565                                        break; 
    6666                                case 'y': 
     
    7070                                                        break; 
    7171                                                case 2: 
    72                                                         s = String(s).substr(-2); 
     72                                                        s = String(s); s = s.substr(s.length - 2); 
    7373                                                        break; 
    7474                                                default: 
     
    103103                                                var type = (c == "L") ? "standalone" : "format"; 
    104104                                                var prop = ["months",type,width].join("-"); 
    105                                                 s = info[prop][m]; 
     105                                                s = bundle[prop][m]; 
    106106                                        } 
    107107                                        break; 
     
    139139                                                var type = (c == "c") ? "standalone" : "format"; 
    140140                                                var prop = ["days",type,width].join("-"); 
    141                                                 s = info[prop][d]; 
     141                                                s = bundle[prop][d]; 
    142142                                        } 
    143143                                        break; 
    144144                                case 'a': 
    145145                                        var timePeriod = (dateObject.getHours() < 12) ? 'am' : 'pm'; 
    146                                         s = info[timePeriod]; 
     146                                        s = bundle[timePeriod]; 
    147147                                        break; 
    148148                                case 'h': 
     
    203203                                case 'g': 
    204204                                case 'A': 
    205                                         dojo.debug(match+" modifier not yet implemented"); 
     205//                                      dojo.debug(match+" modifier not yet implemented"); 
    206206                                        s = "?"; 
    207207                                        break; 
     
    217217 
    218218        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); 
    221221        var str = []; 
    222222        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        } 
    223231        if(options.selector != "timeOnly"){ 
    224                 var datePattern = options.datePattern || info["dateFormat-"+formatLength]; 
     232                var datePattern = options.datePattern || bundle["dateFormat-"+formatLength]; 
    225233                if(datePattern){str.push(_processPattern(datePattern, sauce));} 
    226234        } 
    227235        if(options.selector != "dateOnly"){ 
    228                 var timePattern = options.timePattern || info["timeFormat-"+formatLength]; 
     236                var timePattern = options.timePattern || bundle["timeFormat-"+formatLength]; 
    229237                if(timePattern){str.push(_processPattern(timePattern, sauce));} 
    230238        } 
  • branches/0.4/src/widget/DatePicker.js

    r7305 r8684  
    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 
     
    415424                        function f(n){ 
    416425                                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}); 
    418427                        } 
    419428                        f("previous"); 
  • branches/0.4/src/widget/DropdownDatePicker.js

    r7305 r8684  
    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                        } 
  • branches/0.4/src/widget/templates/DatePicker.html

    r7305 r8684  
    9393                </tfoot> 
    9494        </table> 
     95         
    9596</div>