Changeset 12561

Show
Ignore:
Timestamp:
02/20/08 11:34:04 (11 months ago)
Author:
peller
Message:

Years < 100 are not supported. Pad years < 1000 when formatting. Fixes #5751

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/date/stamp.js

    r12050 r12561  
    2525        //              input may return null.  Arguments which are out of bounds will be handled 
    2626        //              by the Date constructor (e.g. January 32nd typically gets resolved to February 1st) 
     27        //              Only years between 100 and 9999 are supported. 
    2728        // 
    2829        //      formattedString: 
     
    5960                } 
    6061                result = new Date(match[0]||1970, match[1]||0, match[2]||1, match[3]||0, match[4]||0, match[5]||0, match[6]||0); 
     62//              result.setFullYear(match[0]||1970); // for year < 100 
    6163 
    6264                var offset = 0; 
     
    8486        //              When options.selector is omitted, output follows RFC3339 (http://www.ietf.org/rfc/rfc3339.txt) 
    8587        //              The local time zone is included as an offset from GMT, except when selector=='time' (time without a date) 
    86         //              Does not check bounds. 
     88        //              Does not check bounds.  Only years between 100 and 9999 are supported. 
    8789        // 
    8890        //      dateObject: 
     
    9597        //              milliseconds- if true, output milliseconds 
    9698 
    97         var _ = function(n){ return (n < 10) ? "0" + n : n; } 
     99        var _ = function(n){ return (n < 10) ? "0" + n : n; }; 
    98100        options = options || {}; 
    99101        var formattedDate = []; 
     
    101103        var date = ""; 
    102104        if(options.selector != "time"){ 
    103                 date = [dateObject[getter+"FullYear"](), _(dateObject[getter+"Month"]()+1), _(dateObject[getter+"Date"]())].join('-'); 
     105                var year = dateObject[getter+"FullYear"](); 
     106                date = ["0000".substr((year+"").length)+year, _(dateObject[getter+"Month"]()+1), _(dateObject[getter+"Date"]())].join('-'); 
    104107        } 
    105108        formattedDate.push(date);