summaryrefslogtreecommitdiff
path: root/lib/dojo/date
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-08-14 18:59:10 +0400
committerAndrew Dolgov <[email protected]>2012-08-14 18:59:18 +0400
commit1354d17270961fff662d40f90521223f8fd0d73b (patch)
treee9266be71587e47c800303446e968a6d3565e2cf /lib/dojo/date
parentd04f8c826f5283765f52cf6b98b42a1ed8f2d6bc (diff)
update dojo to 1.7.3
Diffstat (limited to 'lib/dojo/date')
-rw-r--r--lib/dojo/date/locale.js673
-rw-r--r--lib/dojo/date/locale.js.uncompressed.js670
-rw-r--r--lib/dojo/date/stamp.js146
-rw-r--r--lib/dojo/date/stamp.js.uncompressed.js146
4 files changed, 820 insertions, 815 deletions
diff --git a/lib/dojo/date/locale.js b/lib/dojo/date/locale.js
index 9b6b4fa62..2d029b014 100644
--- a/lib/dojo/date/locale.js
+++ b/lib/dojo/date/locale.js
@@ -4,674 +4,5 @@
see: http://dojotoolkit.org/license for details
*/
-
-if(!dojo._hasResource["dojo.date.locale"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojo.date.locale"] = true;
-dojo.provide("dojo.date.locale");
-dojo.require("dojo.date");
-dojo.require("dojo.cldr.supplemental");
-dojo.require("dojo.regexp");
-dojo.require("dojo.string");
-dojo.require("dojo.i18n");
-dojo.requireLocalization("dojo.cldr", "gregorian", null, "ROOT,ar,ca,cs,da,de,el,en,en-au,en-ca,en-gb,es,fi,fr,fr-ch,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-hant,zh-hk,zh-tw");
-
-dojo.getObject("date.locale", true, dojo);
-
-// Localization methods for Date. Honor local customs using locale-dependent dojo.cldr data.
-
-
-// Load the bundles containing localization information for
-// names and formats
-
-//NOTE: Everything in this module assumes Gregorian calendars.
-// Other calendars will be implemented in separate modules.
-
-(function(){
- // Format a pattern without literals
- function formatPattern(dateObject, bundle, options, pattern){
- return pattern.replace(/([a-z])\1*/ig, function(match){
- var s, pad,
- c = match.charAt(0),
- l = match.length,
- widthList = ["abbr", "wide", "narrow"];
- switch(c){
- case 'G':
- s = bundle[(l < 4) ? "eraAbbr" : "eraNames"][dateObject.getFullYear() < 0 ? 0 : 1];
- break;
- case 'y':
- s = dateObject.getFullYear();
- switch(l){
- case 1:
- break;
- case 2:
- if(!options.fullYear){
- s = String(s); s = s.substr(s.length - 2);
- break;
- }
- // fallthrough
- default:
- pad = true;
- }
- break;
- case 'Q':
- case 'q':
- s = Math.ceil((dateObject.getMonth()+1)/3);
-// switch(l){
-// case 1: case 2:
- pad = true;
-// break;
-// case 3: case 4: // unimplemented
-// }
- break;
- case 'M':
- var m = dateObject.getMonth();
- if(l<3){
- s = m+1; pad = true;
- }else{
- var propM = ["months", "format", widthList[l-3]].join("-");
- s = bundle[propM][m];
- }
- break;
- case 'w':
- var firstDay = 0;
- s = dojo.date.locale._getWeekOfYear(dateObject, firstDay); pad = true;
- break;
- case 'd':
- s = dateObject.getDate(); pad = true;
- break;
- case 'D':
- s = dojo.date.locale._getDayOfYear(dateObject); pad = true;
- break;
- case 'E':
- var d = dateObject.getDay();
- if(l<3){
- s = d+1; pad = true;
- }else{
- var propD = ["days", "format", widthList[l-3]].join("-");
- s = bundle[propD][d];
- }
- break;
- case 'a':
- var timePeriod = (dateObject.getHours() < 12) ? 'am' : 'pm';
- s = options[timePeriod] || bundle['dayPeriods-format-wide-' + timePeriod];
- break;
- case 'h':
- case 'H':
- case 'K':
- case 'k':
- var h = dateObject.getHours();
- // strange choices in the date format make it impossible to write this succinctly
- switch (c){
- case 'h': // 1-12
- s = (h % 12) || 12;
- break;
- case 'H': // 0-23
- s = h;
- break;
- case 'K': // 0-11
- s = (h % 12);
- break;
- case 'k': // 1-24
- s = h || 24;
- break;
- }
- pad = true;
- break;
- case 'm':
- s = dateObject.getMinutes(); pad = true;
- break;
- case 's':
- s = dateObject.getSeconds(); pad = true;
- break;
- case 'S':
- s = Math.round(dateObject.getMilliseconds() * Math.pow(10, l-3)); pad = true;
- break;
- case 'v': // FIXME: don't know what this is. seems to be same as z?
- case 'z':
- // We only have one timezone to offer; the one from the browser
- s = dojo.date.locale._getZone(dateObject, true, options);
- if(s){break;}
- l=4;
- // fallthrough... use GMT if tz not available
- case 'Z':
- var offset = dojo.date.locale._getZone(dateObject, false, options);
- var tz = [
- (offset<=0 ? "+" : "-"),
- dojo.string.pad(Math.floor(Math.abs(offset)/60), 2),
- dojo.string.pad(Math.abs(offset)% 60, 2)
- ];
- if(l==4){
- tz.splice(0, 0, "GMT");
- tz.splice(3, 0, ":");
- }
- s = tz.join("");
- break;
-// case 'Y': case 'u': case 'W': case 'F': case 'g': case 'A': case 'e':
-// console.log(match+" modifier unimplemented");
- default:
- throw new Error("dojo.date.locale.format: invalid pattern char: "+pattern);
- }
- if(pad){ s = dojo.string.pad(s, l); }
- return s;
- });
- }
-
-/*=====
- dojo.date.locale.__FormatOptions = function(){
- // selector: String
- // choice of 'time','date' (default: date and time)
- // formatLength: String
- // choice of long, short, medium or full (plus any custom additions). Defaults to 'short'
- // datePattern:String
- // override pattern with this string
- // timePattern:String
- // override pattern with this string
- // am: String
- // override strings for am in times
- // pm: String
- // override strings for pm in times
- // locale: String
- // override the locale used to determine formatting rules
- // fullYear: Boolean
- // (format only) use 4 digit years whenever 2 digit years are called for
- // strict: Boolean
- // (parse only) strict parsing, off by default
- this.selector = selector;
- this.formatLength = formatLength;
- this.datePattern = datePattern;
- this.timePattern = timePattern;
- this.am = am;
- this.pm = pm;
- this.locale = locale;
- this.fullYear = fullYear;
- this.strict = strict;
- }
-=====*/
-
-dojo.date.locale._getZone = function(/*Date*/dateObject, /*boolean*/getName, /*dojo.date.locale.__FormatOptions?*/options){
- // summary:
- // Returns the zone (or offset) for the given date and options. This
- // is broken out into a separate function so that it can be overridden
- // by timezone-aware code.
- //
- // dateObject:
- // the date and/or time being formatted.
- //
- // getName:
- // Whether to return the timezone string (if true), or the offset (if false)
- //
- // options:
- // The options being used for formatting
- if(getName){
- return dojo.date.getTimezoneName(dateObject);
- }else{
- return dateObject.getTimezoneOffset();
- }
-};
-
-
-dojo.date.locale.format = function(/*Date*/dateObject, /*dojo.date.locale.__FormatOptions?*/options){
- // summary:
- // Format a Date object as a String, using locale-specific settings.
- //
- // description:
- // Create a string from a Date object using a known localized pattern.
- // By default, this method formats both date and time from dateObject.
- // Formatting patterns are chosen appropriate to the locale. Different
- // formatting lengths may be chosen, with "full" used by default.
- // Custom patterns may be used or registered with translations using
- // the dojo.date.locale.addCustomFormats method.
- // Formatting patterns are implemented using [the syntax described at
- // unicode.org](http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns)
- //
- // dateObject:
- // the date and/or time to be formatted. If a time only is formatted,
- // the values in the year, month, and day fields are irrelevant. The
- // opposite is true when formatting only dates.
-
- options = options || {};
-
- var locale = dojo.i18n.normalizeLocale(options.locale),
- formatLength = options.formatLength || 'short',
- bundle = dojo.date.locale._getGregorianBundle(locale),
- str = [],
- sauce = dojo.hitch(this, formatPattern, dateObject, bundle, options);
- if(options.selector == "year"){
- return _processPattern(bundle["dateFormatItem-yyyy"] || "yyyy", sauce);
- }
- var pattern;
- if(options.selector != "date"){
- pattern = options.timePattern || bundle["timeFormat-"+formatLength];
- if(pattern){str.push(_processPattern(pattern, sauce));}
- }
- if(options.selector != "time"){
- pattern = options.datePattern || bundle["dateFormat-"+formatLength];
- if(pattern){str.push(_processPattern(pattern, sauce));}
- }
-
- return str.length == 1 ? str[0] : bundle["dateTimeFormat-"+formatLength].replace(/\{(\d+)\}/g,
- function(match, key){ return str[key]; }); // String
-};
-
-dojo.date.locale.regexp = function(/*dojo.date.locale.__FormatOptions?*/options){
- // summary:
- // Builds the regular needed to parse a localized date
-
- return dojo.date.locale._parseInfo(options).regexp; // String
-};
-
-dojo.date.locale._parseInfo = function(/*dojo.date.locale.__FormatOptions?*/options){
- options = options || {};
- var locale = dojo.i18n.normalizeLocale(options.locale),
- bundle = dojo.date.locale._getGregorianBundle(locale),
- formatLength = options.formatLength || 'short',
- datePattern = options.datePattern || bundle["dateFormat-" + formatLength],
- timePattern = options.timePattern || bundle["timeFormat-" + formatLength],
- pattern;
- if(options.selector == 'date'){
- pattern = datePattern;
- }else if(options.selector == 'time'){
- pattern = timePattern;
- }else{
- pattern = bundle["dateTimeFormat-"+formatLength].replace(/\{(\d+)\}/g,
- function(match, key){ return [timePattern, datePattern][key]; });
- }
-
- var tokens = [],
- re = _processPattern(pattern, dojo.hitch(this, _buildDateTimeRE, tokens, bundle, options));
- return {regexp: re, tokens: tokens, bundle: bundle};
-};
-
-dojo.date.locale.parse = function(/*String*/value, /*dojo.date.locale.__FormatOptions?*/options){
- // summary:
- // Convert a properly formatted string to a primitive Date object,
- // using locale-specific settings.
- //
- // description:
- // Create a Date object from a string using a known localized pattern.
- // By default, this method parses looking for both date and time in the string.
- // Formatting patterns are chosen appropriate to the locale. Different
- // formatting lengths may be chosen, with "full" used by default.
- // Custom patterns may be used or registered with translations using
- // the dojo.date.locale.addCustomFormats method.
- //
- // Formatting patterns are implemented using [the syntax described at
- // unicode.org](http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns)
- // When two digit years are used, a century is chosen according to a sliding
- // window of 80 years before and 20 years after present year, for both `yy` and `yyyy` patterns.
- // year < 100CE requires strict mode.
- //
- // value:
- // A string representation of a date
-
- // remove non-printing bidi control chars from input and pattern
- var controlChars = /[\u200E\u200F\u202A\u202E]/g,
- info = dojo.date.locale._parseInfo(options),
- tokens = info.tokens, bundle = info.bundle,
- re = new RegExp("^" + info.regexp.replace(controlChars, "") + "$",
- info.strict ? "" : "i"),
- match = re.exec(value && value.replace(controlChars, ""));
-
- if(!match){ return null; } // null
-
- var widthList = ['abbr', 'wide', 'narrow'],
- result = [1970,0,1,0,0,0,0], // will get converted to a Date at the end
- amPm = "",
- valid = dojo.every(match, function(v, i){
- if(!i){return true;}
- var token=tokens[i-1];
- var l=token.length;
- switch(token.charAt(0)){
- case 'y':
- if(l != 2 && options.strict){
- //interpret year literally, so '5' would be 5 A.D.
- result[0] = v;
- }else{
- if(v<100){
- v = Number(v);
- //choose century to apply, according to a sliding window
- //of 80 years before and 20 years after present year
- var year = '' + new Date().getFullYear(),
- century = year.substring(0, 2) * 100,
- cutoff = Math.min(Number(year.substring(2, 4)) + 20, 99),
- num = (v < cutoff) ? century + v : century - 100 + v;
- result[0] = num;
- }else{
- //we expected 2 digits and got more...
- if(options.strict){
- return false;
- }
- //interpret literally, so '150' would be 150 A.D.
- //also tolerate '1950', if 'yyyy' input passed to 'yy' format
- result[0] = v;
- }
- }
- break;
- case 'M':
- if(l>2){
- var months = bundle['months-format-' + widthList[l-3]].concat();
- if(!options.strict){
- //Tolerate abbreviating period in month part
- //Case-insensitive comparison
- v = v.replace(".","").toLowerCase();
- months = dojo.map(months, function(s){ return s.replace(".","").toLowerCase(); } );
- }
- v = dojo.indexOf(months, v);
- if(v == -1){
-// console.log("dojo.date.locale.parse: Could not parse month name: '" + v + "'.");
- return false;
- }
- }else{
- v--;
- }
- result[1] = v;
- break;
- case 'E':
- case 'e':
- var days = bundle['days-format-' + widthList[l-3]].concat();
- if(!options.strict){
- //Case-insensitive comparison
- v = v.toLowerCase();
- days = dojo.map(days, function(d){return d.toLowerCase();});
- }
- v = dojo.indexOf(days, v);
- if(v == -1){
-// console.log("dojo.date.locale.parse: Could not parse weekday name: '" + v + "'.");
- return false;
- }
-
- //TODO: not sure what to actually do with this input,
- //in terms of setting something on the Date obj...?
- //without more context, can't affect the actual date
- //TODO: just validate?
- break;
- case 'D':
- result[1] = 0;
- // fallthrough...
- case 'd':
- result[2] = v;
- break;
- case 'a': //am/pm
- var am = options.am || bundle['dayPeriods-format-wide-am'],
- pm = options.pm || bundle['dayPeriods-format-wide-pm'];
- if(!options.strict){
- var period = /\./g;
- v = v.replace(period,'').toLowerCase();
- am = am.replace(period,'').toLowerCase();
- pm = pm.replace(period,'').toLowerCase();
- }
- if(options.strict && v != am && v != pm){
-// console.log("dojo.date.locale.parse: Could not parse am/pm part.");
- return false;
- }
-
- // we might not have seen the hours field yet, so store the state and apply hour change later
- amPm = (v == pm) ? 'p' : (v == am) ? 'a' : '';
- break;
- case 'K': //hour (1-24)
- if(v == 24){ v = 0; }
- // fallthrough...
- case 'h': //hour (1-12)
- case 'H': //hour (0-23)
- case 'k': //hour (0-11)
- //TODO: strict bounds checking, padding
- if(v > 23){
-// console.log("dojo.date.locale.parse: Illegal hours value");
- return false;
- }
-
- //in the 12-hour case, adjusting for am/pm requires the 'a' part
- //which could come before or after the hour, so we will adjust later
- result[3] = v;
- break;
- case 'm': //minutes
- result[4] = v;
- break;
- case 's': //seconds
- result[5] = v;
- break;
- case 'S': //milliseconds
- result[6] = v;
-// break;
-// case 'w':
-//TODO var firstDay = 0;
-// default:
-//TODO: throw?
-// console.log("dojo.date.locale.parse: unsupported pattern char=" + token.charAt(0));
- }
- return true;
- });
-
- var hours = +result[3];
- if(amPm === 'p' && hours < 12){
- result[3] = hours + 12; //e.g., 3pm -> 15
- }else if(amPm === 'a' && hours == 12){
- result[3] = 0; //12am -> 0
- }
-
- //TODO: implement a getWeekday() method in order to test
- //validity of input strings containing 'EEE' or 'EEEE'...
-
- var dateObject = new Date(result[0], result[1], result[2], result[3], result[4], result[5], result[6]); // Date
- if(options.strict){
- dateObject.setFullYear(result[0]);
- }
-
- // Check for overflow. The Date() constructor normalizes things like April 32nd...
- //TODO: why isn't this done for times as well?
- var allTokens = tokens.join(""),
- dateToken = allTokens.indexOf('d') != -1,
- monthToken = allTokens.indexOf('M') != -1;
-
- if(!valid ||
- (monthToken && dateObject.getMonth() > result[1]) ||
- (dateToken && dateObject.getDate() > result[2])){
- return null;
- }
-
- // Check for underflow, due to DST shifts. See #9366
- // This assumes a 1 hour dst shift correction at midnight
- // We could compare the timezone offset after the shift and add the difference instead.
- if((monthToken && dateObject.getMonth() < result[1]) ||
- (dateToken && dateObject.getDate() < result[2])){
- dateObject = dojo.date.add(dateObject, "hour", 1);
- }
-
- return dateObject; // Date
-};
-
-function _processPattern(pattern, applyPattern, applyLiteral, applyAll){
- //summary: Process a pattern with literals in it
-
- // Break up on single quotes, treat every other one as a literal, except '' which becomes '
- var identity = function(x){return x;};
- applyPattern = applyPattern || identity;
- applyLiteral = applyLiteral || identity;
- applyAll = applyAll || identity;
-
- //split on single quotes (which escape literals in date format strings)
- //but preserve escaped single quotes (e.g., o''clock)
- var chunks = pattern.match(/(''|[^'])+/g),
- literal = pattern.charAt(0) == "'";
-
- dojo.forEach(chunks, function(chunk, i){
- if(!chunk){
- chunks[i]='';
- }else{
- chunks[i]=(literal ? applyLiteral : applyPattern)(chunk.replace(/''/g, "'"));
- literal = !literal;
- }
- });
- return applyAll(chunks.join(''));
-}
-
-function _buildDateTimeRE(tokens, bundle, options, pattern){
- pattern = dojo.regexp.escapeString(pattern);
- if(!options.strict){ pattern = pattern.replace(" a", " ?a"); } // kludge to tolerate no space before am/pm
- return pattern.replace(/([a-z])\1*/ig, function(match){
- // Build a simple regexp. Avoid captures, which would ruin the tokens list
- var s,
- c = match.charAt(0),
- l = match.length,
- p2 = '', p3 = '';
- if(options.strict){
- if(l > 1){ p2 = '0' + '{'+(l-1)+'}'; }
- if(l > 2){ p3 = '0' + '{'+(l-2)+'}'; }
- }else{
- p2 = '0?'; p3 = '0{0,2}';
- }
- switch(c){
- case 'y':
- s = '\\d{2,4}';
- break;
- case 'M':
- s = (l>2) ? '\\S+?' : '1[0-2]|'+p2+'[1-9]';
- break;
- case 'D':
- s = '[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|'+p3+'[1-9][0-9]|'+p2+'[1-9]';
- break;
- case 'd':
- s = '3[01]|[12]\\d|'+p2+'[1-9]';
- break;
- case 'w':
- s = '[1-4][0-9]|5[0-3]|'+p2+'[1-9]';
- break;
- case 'E':
- s = '\\S+';
- break;
- case 'h': //hour (1-12)
- s = '1[0-2]|'+p2+'[1-9]';
- break;
- case 'k': //hour (0-11)
- s = '1[01]|'+p2+'\\d';
- break;
- case 'H': //hour (0-23)
- s = '1\\d|2[0-3]|'+p2+'\\d';
- break;
- case 'K': //hour (1-24)
- s = '1\\d|2[0-4]|'+p2+'[1-9]';
- break;
- case 'm':
- case 's':
- s = '[0-5]\\d';
- break;
- case 'S':
- s = '\\d{'+l+'}';
- break;
- case 'a':
- var am = options.am || bundle['dayPeriods-format-wide-am'],
- pm = options.pm || bundle['dayPeriods-format-wide-pm'];
- s = am + '|' + pm;
- if(!options.strict){
- if(am != am.toLowerCase()){ s += '|' + am.toLowerCase(); }
- if(pm != pm.toLowerCase()){ s += '|' + pm.toLowerCase(); }
- if(s.indexOf('.') != -1){ s += '|' + s.replace(/\./g, ""); }
- }
- s = s.replace(/\./g, "\\.");
- break;
- default:
- // case 'v':
- // case 'z':
- // case 'Z':
- s = ".*";
-// console.log("parse of date format, pattern=" + pattern);
- }
-
- if(tokens){ tokens.push(match); }
-
- return "(" + s + ")"; // add capture
- }).replace(/[\xa0 ]/g, "[\\s\\xa0]"); // normalize whitespace. Need explicit handling of \xa0 for IE.
-}
-})();
-
-(function(){
-var _customFormats = [];
-dojo.date.locale.addCustomFormats = function(/*String*/packageName, /*String*/bundleName){
- // summary:
- // Add a reference to a bundle containing localized custom formats to be
- // used by date/time formatting and parsing routines.
- //
- // description:
- // The user may add custom localized formats where the bundle has properties following the
- // same naming convention used by dojo.cldr: `dateFormat-xxxx` / `timeFormat-xxxx`
- // The pattern string should match the format used by the CLDR.
- // See dojo.date.locale.format() for details.
- // The resources must be loaded by dojo.requireLocalization() prior to use
-
- _customFormats.push({pkg:packageName,name:bundleName});
-};
-
-dojo.date.locale._getGregorianBundle = function(/*String*/locale){
- var gregorian = {};
- dojo.forEach(_customFormats, function(desc){
- var bundle = dojo.i18n.getLocalization(desc.pkg, desc.name, locale);
- gregorian = dojo.mixin(gregorian, bundle);
- }, this);
- return gregorian; /*Object*/
-};
-})();
-
-dojo.date.locale.addCustomFormats("dojo.cldr","gregorian");
-
-dojo.date.locale.getNames = function(/*String*/item, /*String*/type, /*String?*/context, /*String?*/locale){
- // summary:
- // Used to get localized strings from dojo.cldr for day or month names.
- //
- // item:
- // 'months' || 'days'
- // type:
- // 'wide' || 'narrow' || 'abbr' (e.g. "Monday", "Mon", or "M" respectively, in English)
- // context:
- // 'standAlone' || 'format' (default)
- // locale:
- // override locale used to find the names
-
- var label,
- lookup = dojo.date.locale._getGregorianBundle(locale),
- props = [item, context, type];
- if(context == 'standAlone'){
- var key = props.join('-');
- label = lookup[key];
- // Fall back to 'format' flavor of name
- if(label[0] == 1){ label = undefined; } // kludge, in the absence of real aliasing support in dojo.cldr
- }
- props[1] = 'format';
-
- // return by copy so changes won't be made accidentally to the in-memory model
- return (label || lookup[props.join('-')]).concat(); /*Array*/
-};
-
-dojo.date.locale.isWeekend = function(/*Date?*/dateObject, /*String?*/locale){
- // summary:
- // Determines if the date falls on a weekend, according to local custom.
-
- var weekend = dojo.cldr.supplemental.getWeekend(locale),
- day = (dateObject || new Date()).getDay();
- if(weekend.end < weekend.start){
- weekend.end += 7;
- if(day < weekend.start){ day += 7; }
- }
- return day >= weekend.start && day <= weekend.end; // Boolean
-};
-
-// These are used only by format and strftime. Do they need to be public? Which module should they go in?
-
-dojo.date.locale._getDayOfYear = function(/*Date*/dateObject){
- // summary: gets the day of the year as represented by dateObject
- return dojo.date.difference(new Date(dateObject.getFullYear(), 0, 1, dateObject.getHours()), dateObject) + 1; // Number
-};
-
-dojo.date.locale._getWeekOfYear = function(/*Date*/dateObject, /*Number*/firstDayOfWeek){
- if(arguments.length == 1){ firstDayOfWeek = 0; } // Sunday
-
- var firstDayOfYear = new Date(dateObject.getFullYear(), 0, 1).getDay(),
- adj = (firstDayOfYear - firstDayOfWeek + 7) % 7,
- week = Math.floor((dojo.date.locale._getDayOfYear(dateObject) + adj - 1) / 7);
-
- // if year starts on the specified day, start counting weeks at 1
- if(firstDayOfYear == firstDayOfWeek){ week++; }
-
- return week; // Number
-};
-
-}
+//>>built
+define("dojo/date/locale",["../_base/kernel","../_base/lang","../_base/array","../date","../cldr/supplemental","../regexp","../string","../i18n!../cldr/nls/gregorian"],function(_1,_2,_3,_4,_5,_6,_7,_8){_2.getObject("date.locale",true,_1);function _9(_a,_b,_c,_d){return _d.replace(/([a-z])\1*/ig,function(_e){var s,_f,c=_e.charAt(0),l=_e.length,_10=["abbr","wide","narrow"];switch(c){case "G":s=_b[(l<4)?"eraAbbr":"eraNames"][_a.getFullYear()<0?0:1];break;case "y":s=_a.getFullYear();switch(l){case 1:break;case 2:if(!_c.fullYear){s=String(s);s=s.substr(s.length-2);break;}default:_f=true;}break;case "Q":case "q":s=Math.ceil((_a.getMonth()+1)/3);_f=true;break;case "M":var m=_a.getMonth();if(l<3){s=m+1;_f=true;}else{var _11=["months","format",_10[l-3]].join("-");s=_b[_11][m];}break;case "w":var _12=0;s=_1.date.locale._getWeekOfYear(_a,_12);_f=true;break;case "d":s=_a.getDate();_f=true;break;case "D":s=_1.date.locale._getDayOfYear(_a);_f=true;break;case "E":var d=_a.getDay();if(l<3){s=d+1;_f=true;}else{var _13=["days","format",_10[l-3]].join("-");s=_b[_13][d];}break;case "a":var _14=(_a.getHours()<12)?"am":"pm";s=_c[_14]||_b["dayPeriods-format-wide-"+_14];break;case "h":case "H":case "K":case "k":var h=_a.getHours();switch(c){case "h":s=(h%12)||12;break;case "H":s=h;break;case "K":s=(h%12);break;case "k":s=h||24;break;}_f=true;break;case "m":s=_a.getMinutes();_f=true;break;case "s":s=_a.getSeconds();_f=true;break;case "S":s=Math.round(_a.getMilliseconds()*Math.pow(10,l-3));_f=true;break;case "v":case "z":s=_1.date.locale._getZone(_a,true,_c);if(s){break;}l=4;case "Z":var _15=_1.date.locale._getZone(_a,false,_c);var tz=[(_15<=0?"+":"-"),_7.pad(Math.floor(Math.abs(_15)/60),2),_7.pad(Math.abs(_15)%60,2)];if(l==4){tz.splice(0,0,"GMT");tz.splice(3,0,":");}s=tz.join("");break;default:throw new Error("dojo.date.locale.format: invalid pattern char: "+_d);}if(_f){s=_7.pad(s,l);}return s;});};_1.date.locale._getZone=function(_16,_17,_18){if(_17){return _4.getTimezoneName(_16);}else{return _16.getTimezoneOffset();}};_1.date.locale.format=function(_19,_1a){_1a=_1a||{};var _1b=_1.i18n.normalizeLocale(_1a.locale),_1c=_1a.formatLength||"short",_1d=_1.date.locale._getGregorianBundle(_1b),str=[],_1e=_2.hitch(this,_9,_19,_1d,_1a);if(_1a.selector=="year"){return _1f(_1d["dateFormatItem-yyyy"]||"yyyy",_1e);}var _20;if(_1a.selector!="date"){_20=_1a.timePattern||_1d["timeFormat-"+_1c];if(_20){str.push(_1f(_20,_1e));}}if(_1a.selector!="time"){_20=_1a.datePattern||_1d["dateFormat-"+_1c];if(_20){str.push(_1f(_20,_1e));}}return str.length==1?str[0]:_1d["dateTimeFormat-"+_1c].replace(/\{(\d+)\}/g,function(_21,key){return str[key];});};_1.date.locale.regexp=function(_22){return _1.date.locale._parseInfo(_22).regexp;};_1.date.locale._parseInfo=function(_23){_23=_23||{};var _24=_1.i18n.normalizeLocale(_23.locale),_25=_1.date.locale._getGregorianBundle(_24),_26=_23.formatLength||"short",_27=_23.datePattern||_25["dateFormat-"+_26],_28=_23.timePattern||_25["timeFormat-"+_26],_29;if(_23.selector=="date"){_29=_27;}else{if(_23.selector=="time"){_29=_28;}else{_29=_25["dateTimeFormat-"+_26].replace(/\{(\d+)\}/g,function(_2a,key){return [_28,_27][key];});}}var _2b=[],re=_1f(_29,_2.hitch(this,_2c,_2b,_25,_23));return {regexp:re,tokens:_2b,bundle:_25};};_1.date.locale.parse=function(_2d,_2e){var _2f=/[\u200E\u200F\u202A\u202E]/g,_30=_1.date.locale._parseInfo(_2e),_31=_30.tokens,_32=_30.bundle,re=new RegExp("^"+_30.regexp.replace(_2f,"")+"$",_30.strict?"":"i"),_33=re.exec(_2d&&_2d.replace(_2f,""));if(!_33){return null;}var _34=["abbr","wide","narrow"],_35=[1970,0,1,0,0,0,0],_36="",_37=_1.every(_33,function(v,i){if(!i){return true;}var _38=_31[i-1];var l=_38.length;switch(_38.charAt(0)){case "y":if(l!=2&&_2e.strict){_35[0]=v;}else{if(v<100){v=Number(v);var _39=""+new Date().getFullYear(),_3a=_39.substring(0,2)*100,_3b=Math.min(Number(_39.substring(2,4))+20,99);_35[0]=(v<_3b)?_3a+v:_3a-100+v;}else{if(_2e.strict){return false;}_35[0]=v;}}break;case "M":if(l>2){var _3c=_32["months-format-"+_34[l-3]].concat();if(!_2e.strict){v=v.replace(".","").toLowerCase();_3c=_1.map(_3c,function(s){return s.replace(".","").toLowerCase();});}v=_1.indexOf(_3c,v);if(v==-1){return false;}}else{v--;}_35[1]=v;break;case "E":case "e":var _3d=_32["days-format-"+_34[l-3]].concat();if(!_2e.strict){v=v.toLowerCase();_3d=_1.map(_3d,function(d){return d.toLowerCase();});}v=_1.indexOf(_3d,v);if(v==-1){return false;}break;case "D":_35[1]=0;case "d":_35[2]=v;break;case "a":var am=_2e.am||_32["dayPeriods-format-wide-am"],pm=_2e.pm||_32["dayPeriods-format-wide-pm"];if(!_2e.strict){var _3e=/\./g;v=v.replace(_3e,"").toLowerCase();am=am.replace(_3e,"").toLowerCase();pm=pm.replace(_3e,"").toLowerCase();}if(_2e.strict&&v!=am&&v!=pm){return false;}_36=(v==pm)?"p":(v==am)?"a":"";break;case "K":if(v==24){v=0;}case "h":case "H":case "k":if(v>23){return false;}_35[3]=v;break;case "m":_35[4]=v;break;case "s":_35[5]=v;break;case "S":_35[6]=v;}return true;});var _3f=+_35[3];if(_36==="p"&&_3f<12){_35[3]=_3f+12;}else{if(_36==="a"&&_3f==12){_35[3]=0;}}var _40=new Date(_35[0],_35[1],_35[2],_35[3],_35[4],_35[5],_35[6]);if(_2e.strict){_40.setFullYear(_35[0]);}var _41=_31.join(""),_42=_41.indexOf("d")!=-1,_43=_41.indexOf("M")!=-1;if(!_37||(_43&&_40.getMonth()>_35[1])||(_42&&_40.getDate()>_35[2])){return null;}if((_43&&_40.getMonth()<_35[1])||(_42&&_40.getDate()<_35[2])){_40=_4.add(_40,"hour",1);}return _40;};function _1f(_44,_45,_46,_47){var _48=function(x){return x;};_45=_45||_48;_46=_46||_48;_47=_47||_48;var _49=_44.match(/(''|[^'])+/g),_4a=_44.charAt(0)=="'";_1.forEach(_49,function(_4b,i){if(!_4b){_49[i]="";}else{_49[i]=(_4a?_46:_45)(_4b.replace(/''/g,"'"));_4a=!_4a;}});return _47(_49.join(""));};function _2c(_4c,_4d,_4e,_4f){_4f=_6.escapeString(_4f);if(!_4e.strict){_4f=_4f.replace(" a"," ?a");}return _4f.replace(/([a-z])\1*/ig,function(_50){var s,c=_50.charAt(0),l=_50.length,p2="",p3="";if(_4e.strict){if(l>1){p2="0"+"{"+(l-1)+"}";}if(l>2){p3="0"+"{"+(l-2)+"}";}}else{p2="0?";p3="0{0,2}";}switch(c){case "y":s="\\d{2,4}";break;case "M":s=(l>2)?"\\S+?":"1[0-2]|"+p2+"[1-9]";break;case "D":s="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+p2+"[1-9][0-9]|"+p3+"[1-9]";break;case "d":s="3[01]|[12]\\d|"+p2+"[1-9]";break;case "w":s="[1-4][0-9]|5[0-3]|"+p2+"[1-9]";break;case "E":s="\\S+";break;case "h":s="1[0-2]|"+p2+"[1-9]";break;case "k":s="1[01]|"+p2+"\\d";break;case "H":s="1\\d|2[0-3]|"+p2+"\\d";break;case "K":s="1\\d|2[0-4]|"+p2+"[1-9]";break;case "m":case "s":s="[0-5]\\d";break;case "S":s="\\d{"+l+"}";break;case "a":var am=_4e.am||_4d["dayPeriods-format-wide-am"],pm=_4e.pm||_4d["dayPeriods-format-wide-pm"];s=am+"|"+pm;if(!_4e.strict){if(am!=am.toLowerCase()){s+="|"+am.toLowerCase();}if(pm!=pm.toLowerCase()){s+="|"+pm.toLowerCase();}if(s.indexOf(".")!=-1){s+="|"+s.replace(/\./g,"");}}s=s.replace(/\./g,"\\.");break;default:s=".*";}if(_4c){_4c.push(_50);}return "("+s+")";}).replace(/[\xa0 ]/g,"[\\s\\xa0]");};var _51=[];_1.date.locale.addCustomFormats=function(_52,_53){_51.push({pkg:_52,name:_53});};_1.date.locale._getGregorianBundle=function(_54){var _55={};_1.forEach(_51,function(_56){var _57=_1.i18n.getLocalization(_56.pkg,_56.name,_54);_55=_2.mixin(_55,_57);},this);return _55;};_1.date.locale.addCustomFormats("dojo.cldr","gregorian");_1.date.locale.getNames=function(_58,_59,_5a,_5b){var _5c,_5d=_1.date.locale._getGregorianBundle(_5b),_5e=[_58,_5a,_59];if(_5a=="standAlone"){var key=_5e.join("-");_5c=_5d[key];if(_5c[0]==1){_5c=undefined;}}_5e[1]="format";return (_5c||_5d[_5e.join("-")]).concat();};_1.date.locale.isWeekend=function(_5f,_60){var _61=_5.getWeekend(_60),day=(_5f||new Date()).getDay();if(_61.end<_61.start){_61.end+=7;if(day<_61.start){day+=7;}}return day>=_61.start&&day<=_61.end;};_1.date.locale._getDayOfYear=function(_62){return _4.difference(new Date(_62.getFullYear(),0,1,_62.getHours()),_62)+1;};_1.date.locale._getWeekOfYear=function(_63,_64){if(arguments.length==1){_64=0;}var _65=new Date(_63.getFullYear(),0,1).getDay(),adj=(_65-_64+7)%7,_66=Math.floor((_1.date.locale._getDayOfYear(_63)+adj-1)/7);if(_65==_64){_66++;}return _66;};return _1.date.locale;}); \ No newline at end of file
diff --git a/lib/dojo/date/locale.js.uncompressed.js b/lib/dojo/date/locale.js.uncompressed.js
new file mode 100644
index 000000000..bf4682b39
--- /dev/null
+++ b/lib/dojo/date/locale.js.uncompressed.js
@@ -0,0 +1,670 @@
+define("dojo/date/locale", [
+ "../_base/kernel",
+ "../_base/lang",
+ "../_base/array",
+ "../date",
+ "../cldr/supplemental",
+ "../regexp",
+ "../string",
+ "../i18n!../cldr/nls/gregorian"
+], function(dojo, lang, array, date, cldr, regexp, string, gregorian) {
+ // module:
+ // dojo/date/locale
+ // summary:
+ // This modules defines dojo.date.locale, localization methods for Date.
+
+lang.getObject("date.locale", true, dojo);
+
+// Localization methods for Date. Honor local customs using locale-dependent dojo.cldr data.
+
+// Load the bundles containing localization information for
+// names and formats
+
+//NOTE: Everything in this module assumes Gregorian calendars.
+// Other calendars will be implemented in separate modules.
+
+ // Format a pattern without literals
+ function formatPattern(dateObject, bundle, options, pattern){
+ return pattern.replace(/([a-z])\1*/ig, function(match){
+ var s, pad,
+ c = match.charAt(0),
+ l = match.length,
+ widthList = ["abbr", "wide", "narrow"];
+ switch(c){
+ case 'G':
+ s = bundle[(l < 4) ? "eraAbbr" : "eraNames"][dateObject.getFullYear() < 0 ? 0 : 1];
+ break;
+ case 'y':
+ s = dateObject.getFullYear();
+ switch(l){
+ case 1:
+ break;
+ case 2:
+ if(!options.fullYear){
+ s = String(s); s = s.substr(s.length - 2);
+ break;
+ }
+ // fallthrough
+ default:
+ pad = true;
+ }
+ break;
+ case 'Q':
+ case 'q':
+ s = Math.ceil((dateObject.getMonth()+1)/3);
+// switch(l){
+// case 1: case 2:
+ pad = true;
+// break;
+// case 3: case 4: // unimplemented
+// }
+ break;
+ case 'M':
+ var m = dateObject.getMonth();
+ if(l<3){
+ s = m+1; pad = true;
+ }else{
+ var propM = ["months", "format", widthList[l-3]].join("-");
+ s = bundle[propM][m];
+ }
+ break;
+ case 'w':
+ var firstDay = 0;
+ s = dojo.date.locale._getWeekOfYear(dateObject, firstDay); pad = true;
+ break;
+ case 'd':
+ s = dateObject.getDate(); pad = true;
+ break;
+ case 'D':
+ s = dojo.date.locale._getDayOfYear(dateObject); pad = true;
+ break;
+ case 'E':
+ var d = dateObject.getDay();
+ if(l<3){
+ s = d+1; pad = true;
+ }else{
+ var propD = ["days", "format", widthList[l-3]].join("-");
+ s = bundle[propD][d];
+ }
+ break;
+ case 'a':
+ var timePeriod = (dateObject.getHours() < 12) ? 'am' : 'pm';
+ s = options[timePeriod] || bundle['dayPeriods-format-wide-' + timePeriod];
+ break;
+ case 'h':
+ case 'H':
+ case 'K':
+ case 'k':
+ var h = dateObject.getHours();
+ // strange choices in the date format make it impossible to write this succinctly
+ switch (c){
+ case 'h': // 1-12
+ s = (h % 12) || 12;
+ break;
+ case 'H': // 0-23
+ s = h;
+ break;
+ case 'K': // 0-11
+ s = (h % 12);
+ break;
+ case 'k': // 1-24
+ s = h || 24;
+ break;
+ }
+ pad = true;
+ break;
+ case 'm':
+ s = dateObject.getMinutes(); pad = true;
+ break;
+ case 's':
+ s = dateObject.getSeconds(); pad = true;
+ break;
+ case 'S':
+ s = Math.round(dateObject.getMilliseconds() * Math.pow(10, l-3)); pad = true;
+ break;
+ case 'v': // FIXME: don't know what this is. seems to be same as z?
+ case 'z':
+ // We only have one timezone to offer; the one from the browser
+ s = dojo.date.locale._getZone(dateObject, true, options);
+ if(s){break;}
+ l=4;
+ // fallthrough... use GMT if tz not available
+ case 'Z':
+ var offset = dojo.date.locale._getZone(dateObject, false, options);
+ var tz = [
+ (offset<=0 ? "+" : "-"),
+ string.pad(Math.floor(Math.abs(offset)/60), 2),
+ string.pad(Math.abs(offset)% 60, 2)
+ ];
+ if(l==4){
+ tz.splice(0, 0, "GMT");
+ tz.splice(3, 0, ":");
+ }
+ s = tz.join("");
+ break;
+// case 'Y': case 'u': case 'W': case 'F': case 'g': case 'A': case 'e':
+// console.log(match+" modifier unimplemented");
+ default:
+ throw new Error("dojo.date.locale.format: invalid pattern char: "+pattern);
+ }
+ if(pad){ s = string.pad(s, l); }
+ return s;
+ });
+ }
+
+/*=====
+ dojo.date.locale.__FormatOptions = function(){
+ // selector: String
+ // choice of 'time','date' (default: date and time)
+ // formatLength: String
+ // choice of long, short, medium or full (plus any custom additions). Defaults to 'short'
+ // datePattern:String
+ // override pattern with this string
+ // timePattern:String
+ // override pattern with this string
+ // am: String
+ // override strings for am in times
+ // pm: String
+ // override strings for pm in times
+ // locale: String
+ // override the locale used to determine formatting rules
+ // fullYear: Boolean
+ // (format only) use 4 digit years whenever 2 digit years are called for
+ // strict: Boolean
+ // (parse only) strict parsing, off by default
+ this.selector = selector;
+ this.formatLength = formatLength;
+ this.datePattern = datePattern;
+ this.timePattern = timePattern;
+ this.am = am;
+ this.pm = pm;
+ this.locale = locale;
+ this.fullYear = fullYear;
+ this.strict = strict;
+ }
+=====*/
+
+dojo.date.locale._getZone = function(/*Date*/dateObject, /*boolean*/getName, /*dojo.date.locale.__FormatOptions?*/options){
+ // summary:
+ // Returns the zone (or offset) for the given date and options. This
+ // is broken out into a separate function so that it can be overridden
+ // by timezone-aware code.
+ //
+ // dateObject:
+ // the date and/or time being formatted.
+ //
+ // getName:
+ // Whether to return the timezone string (if true), or the offset (if false)
+ //
+ // options:
+ // The options being used for formatting
+ if(getName){
+ return date.getTimezoneName(dateObject);
+ }else{
+ return dateObject.getTimezoneOffset();
+ }
+};
+
+
+dojo.date.locale.format = function(/*Date*/dateObject, /*dojo.date.locale.__FormatOptions?*/options){
+ // summary:
+ // Format a Date object as a String, using locale-specific settings.
+ //
+ // description:
+ // Create a string from a Date object using a known localized pattern.
+ // By default, this method formats both date and time from dateObject.
+ // Formatting patterns are chosen appropriate to the locale. Different
+ // formatting lengths may be chosen, with "full" used by default.
+ // Custom patterns may be used or registered with translations using
+ // the dojo.date.locale.addCustomFormats method.
+ // Formatting patterns are implemented using [the syntax described at
+ // unicode.org](http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns)
+ //
+ // dateObject:
+ // the date and/or time to be formatted. If a time only is formatted,
+ // the values in the year, month, and day fields are irrelevant. The
+ // opposite is true when formatting only dates.
+
+ options = options || {};
+
+ var locale = dojo.i18n.normalizeLocale(options.locale),
+ formatLength = options.formatLength || 'short',
+ bundle = dojo.date.locale._getGregorianBundle(locale),
+ str = [],
+ sauce = lang.hitch(this, formatPattern, dateObject, bundle, options);
+ if(options.selector == "year"){
+ return _processPattern(bundle["dateFormatItem-yyyy"] || "yyyy", sauce);
+ }
+ var pattern;
+ if(options.selector != "date"){
+ pattern = options.timePattern || bundle["timeFormat-"+formatLength];
+ if(pattern){str.push(_processPattern(pattern, sauce));}
+ }
+ if(options.selector != "time"){
+ pattern = options.datePattern || bundle["dateFormat-"+formatLength];
+ if(pattern){str.push(_processPattern(pattern, sauce));}
+ }
+
+ return str.length == 1 ? str[0] : bundle["dateTimeFormat-"+formatLength].replace(/\{(\d+)\}/g,
+ function(match, key){ return str[key]; }); // String
+};
+
+dojo.date.locale.regexp = function(/*dojo.date.locale.__FormatOptions?*/options){
+ // summary:
+ // Builds the regular needed to parse a localized date
+
+ return dojo.date.locale._parseInfo(options).regexp; // String
+};
+
+dojo.date.locale._parseInfo = function(/*dojo.date.locale.__FormatOptions?*/options){
+ options = options || {};
+ var locale = dojo.i18n.normalizeLocale(options.locale),
+ bundle = dojo.date.locale._getGregorianBundle(locale),
+ formatLength = options.formatLength || 'short',
+ datePattern = options.datePattern || bundle["dateFormat-" + formatLength],
+ timePattern = options.timePattern || bundle["timeFormat-" + formatLength],
+ pattern;
+ if(options.selector == 'date'){
+ pattern = datePattern;
+ }else if(options.selector == 'time'){
+ pattern = timePattern;
+ }else{
+ pattern = bundle["dateTimeFormat-"+formatLength].replace(/\{(\d+)\}/g,
+ function(match, key){ return [timePattern, datePattern][key]; });
+ }
+
+ var tokens = [],
+ re = _processPattern(pattern, lang.hitch(this, _buildDateTimeRE, tokens, bundle, options));
+ return {regexp: re, tokens: tokens, bundle: bundle};
+};
+
+dojo.date.locale.parse = function(/*String*/value, /*dojo.date.locale.__FormatOptions?*/options){
+ // summary:
+ // Convert a properly formatted string to a primitive Date object,
+ // using locale-specific settings.
+ //
+ // description:
+ // Create a Date object from a string using a known localized pattern.
+ // By default, this method parses looking for both date and time in the string.
+ // Formatting patterns are chosen appropriate to the locale. Different
+ // formatting lengths may be chosen, with "full" used by default.
+ // Custom patterns may be used or registered with translations using
+ // the dojo.date.locale.addCustomFormats method.
+ //
+ // Formatting patterns are implemented using [the syntax described at
+ // unicode.org](http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns)
+ // When two digit years are used, a century is chosen according to a sliding
+ // window of 80 years before and 20 years after present year, for both `yy` and `yyyy` patterns.
+ // year < 100CE requires strict mode.
+ //
+ // value:
+ // A string representation of a date
+
+ // remove non-printing bidi control chars from input and pattern
+ var controlChars = /[\u200E\u200F\u202A\u202E]/g,
+ info = dojo.date.locale._parseInfo(options),
+ tokens = info.tokens, bundle = info.bundle,
+ re = new RegExp("^" + info.regexp.replace(controlChars, "") + "$",
+ info.strict ? "" : "i"),
+ match = re.exec(value && value.replace(controlChars, ""));
+
+ if(!match){ return null; } // null
+
+ var widthList = ['abbr', 'wide', 'narrow'],
+ result = [1970,0,1,0,0,0,0], // will get converted to a Date at the end
+ amPm = "",
+ valid = dojo.every(match, function(v, i){
+ if(!i){return true;}
+ var token=tokens[i-1];
+ var l=token.length;
+ switch(token.charAt(0)){
+ case 'y':
+ if(l != 2 && options.strict){
+ //interpret year literally, so '5' would be 5 A.D.
+ result[0] = v;
+ }else{
+ if(v<100){
+ v = Number(v);
+ //choose century to apply, according to a sliding window
+ //of 80 years before and 20 years after present year
+ var year = '' + new Date().getFullYear(),
+ century = year.substring(0, 2) * 100,
+ cutoff = Math.min(Number(year.substring(2, 4)) + 20, 99);
+ result[0] = (v < cutoff) ? century + v : century - 100 + v;
+ }else{
+ //we expected 2 digits and got more...
+ if(options.strict){
+ return false;
+ }
+ //interpret literally, so '150' would be 150 A.D.
+ //also tolerate '1950', if 'yyyy' input passed to 'yy' format
+ result[0] = v;
+ }
+ }
+ break;
+ case 'M':
+ if(l>2){
+ var months = bundle['months-format-' + widthList[l-3]].concat();
+ if(!options.strict){
+ //Tolerate abbreviating period in month part
+ //Case-insensitive comparison
+ v = v.replace(".","").toLowerCase();
+ months = dojo.map(months, function(s){ return s.replace(".","").toLowerCase(); } );
+ }
+ v = dojo.indexOf(months, v);
+ if(v == -1){
+// console.log("dojo.date.locale.parse: Could not parse month name: '" + v + "'.");
+ return false;
+ }
+ }else{
+ v--;
+ }
+ result[1] = v;
+ break;
+ case 'E':
+ case 'e':
+ var days = bundle['days-format-' + widthList[l-3]].concat();
+ if(!options.strict){
+ //Case-insensitive comparison
+ v = v.toLowerCase();
+ days = dojo.map(days, function(d){return d.toLowerCase();});
+ }
+ v = dojo.indexOf(days, v);
+ if(v == -1){
+// console.log("dojo.date.locale.parse: Could not parse weekday name: '" + v + "'.");
+ return false;
+ }
+
+ //TODO: not sure what to actually do with this input,
+ //in terms of setting something on the Date obj...?
+ //without more context, can't affect the actual date
+ //TODO: just validate?
+ break;
+ case 'D':
+ result[1] = 0;
+ // fallthrough...
+ case 'd':
+ result[2] = v;
+ break;
+ case 'a': //am/pm
+ var am = options.am || bundle['dayPeriods-format-wide-am'],
+ pm = options.pm || bundle['dayPeriods-format-wide-pm'];
+ if(!options.strict){
+ var period = /\./g;
+ v = v.replace(period,'').toLowerCase();
+ am = am.replace(period,'').toLowerCase();
+ pm = pm.replace(period,'').toLowerCase();
+ }
+ if(options.strict && v != am && v != pm){
+// console.log("dojo.date.locale.parse: Could not parse am/pm part.");
+ return false;
+ }
+
+ // we might not have seen the hours field yet, so store the state and apply hour change later
+ amPm = (v == pm) ? 'p' : (v == am) ? 'a' : '';
+ break;
+ case 'K': //hour (1-24)
+ if(v == 24){ v = 0; }
+ // fallthrough...
+ case 'h': //hour (1-12)
+ case 'H': //hour (0-23)
+ case 'k': //hour (0-11)
+ //TODO: strict bounds checking, padding
+ if(v > 23){
+// console.log("dojo.date.locale.parse: Illegal hours value");
+ return false;
+ }
+
+ //in the 12-hour case, adjusting for am/pm requires the 'a' part
+ //which could come before or after the hour, so we will adjust later
+ result[3] = v;
+ break;
+ case 'm': //minutes
+ result[4] = v;
+ break;
+ case 's': //seconds
+ result[5] = v;
+ break;
+ case 'S': //milliseconds
+ result[6] = v;
+// break;
+// case 'w':
+//TODO var firstDay = 0;
+// default:
+//TODO: throw?
+// console.log("dojo.date.locale.parse: unsupported pattern char=" + token.charAt(0));
+ }
+ return true;
+ });
+
+ var hours = +result[3];
+ if(amPm === 'p' && hours < 12){
+ result[3] = hours + 12; //e.g., 3pm -> 15
+ }else if(amPm === 'a' && hours == 12){
+ result[3] = 0; //12am -> 0
+ }
+
+ //TODO: implement a getWeekday() method in order to test
+ //validity of input strings containing 'EEE' or 'EEEE'...
+
+ var dateObject = new Date(result[0], result[1], result[2], result[3], result[4], result[5], result[6]); // Date
+ if(options.strict){
+ dateObject.setFullYear(result[0]);
+ }
+
+ // Check for overflow. The Date() constructor normalizes things like April 32nd...
+ //TODO: why isn't this done for times as well?
+ var allTokens = tokens.join(""),
+ dateToken = allTokens.indexOf('d') != -1,
+ monthToken = allTokens.indexOf('M') != -1;
+
+ if(!valid ||
+ (monthToken && dateObject.getMonth() > result[1]) ||
+ (dateToken && dateObject.getDate() > result[2])){
+ return null;
+ }
+
+ // Check for underflow, due to DST shifts. See #9366
+ // This assumes a 1 hour dst shift correction at midnight
+ // We could compare the timezone offset after the shift and add the difference instead.
+ if((monthToken && dateObject.getMonth() < result[1]) ||
+ (dateToken && dateObject.getDate() < result[2])){
+ dateObject = date.add(dateObject, "hour", 1);
+ }
+
+ return dateObject; // Date
+};
+
+function _processPattern(pattern, applyPattern, applyLiteral, applyAll){
+ //summary: Process a pattern with literals in it
+
+ // Break up on single quotes, treat every other one as a literal, except '' which becomes '
+ var identity = function(x){return x;};
+ applyPattern = applyPattern || identity;
+ applyLiteral = applyLiteral || identity;
+ applyAll = applyAll || identity;
+
+ //split on single quotes (which escape literals in date format strings)
+ //but preserve escaped single quotes (e.g., o''clock)
+ var chunks = pattern.match(/(''|[^'])+/g),
+ literal = pattern.charAt(0) == "'";
+
+ dojo.forEach(chunks, function(chunk, i){
+ if(!chunk){
+ chunks[i]='';
+ }else{
+ chunks[i]=(literal ? applyLiteral : applyPattern)(chunk.replace(/''/g, "'"));
+ literal = !literal;
+ }
+ });
+ return applyAll(chunks.join(''));
+}
+
+function _buildDateTimeRE(tokens, bundle, options, pattern){
+ pattern = regexp.escapeString(pattern);
+ if(!options.strict){ pattern = pattern.replace(" a", " ?a"); } // kludge to tolerate no space before am/pm
+ return pattern.replace(/([a-z])\1*/ig, function(match){
+ // Build a simple regexp. Avoid captures, which would ruin the tokens list
+ var s,
+ c = match.charAt(0),
+ l = match.length,
+ p2 = '', p3 = '';
+ if(options.strict){
+ if(l > 1){ p2 = '0' + '{'+(l-1)+'}'; }
+ if(l > 2){ p3 = '0' + '{'+(l-2)+'}'; }
+ }else{
+ p2 = '0?'; p3 = '0{0,2}';
+ }
+ switch(c){
+ case 'y':
+ s = '\\d{2,4}';
+ break;
+ case 'M':
+ s = (l>2) ? '\\S+?' : '1[0-2]|'+p2+'[1-9]';
+ break;
+ case 'D':
+ s = '[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|'+p2+'[1-9][0-9]|'+p3+'[1-9]';
+ break;
+ case 'd':
+ s = '3[01]|[12]\\d|'+p2+'[1-9]';
+ break;
+ case 'w':
+ s = '[1-4][0-9]|5[0-3]|'+p2+'[1-9]';
+ break;
+ case 'E':
+ s = '\\S+';
+ break;
+ case 'h': //hour (1-12)
+ s = '1[0-2]|'+p2+'[1-9]';
+ break;
+ case 'k': //hour (0-11)
+ s = '1[01]|'+p2+'\\d';
+ break;
+ case 'H': //hour (0-23)
+ s = '1\\d|2[0-3]|'+p2+'\\d';
+ break;
+ case 'K': //hour (1-24)
+ s = '1\\d|2[0-4]|'+p2+'[1-9]';
+ break;
+ case 'm':
+ case 's':
+ s = '[0-5]\\d';
+ break;
+ case 'S':
+ s = '\\d{'+l+'}';
+ break;
+ case 'a':
+ var am = options.am || bundle['dayPeriods-format-wide-am'],
+ pm = options.pm || bundle['dayPeriods-format-wide-pm'];
+ s = am + '|' + pm;
+ if(!options.strict){
+ if(am != am.toLowerCase()){ s += '|' + am.toLowerCase(); }
+ if(pm != pm.toLowerCase()){ s += '|' + pm.toLowerCase(); }
+ if(s.indexOf('.') != -1){ s += '|' + s.replace(/\./g, ""); }
+ }
+ s = s.replace(/\./g, "\\.");
+ break;
+ default:
+ // case 'v':
+ // case 'z':
+ // case 'Z':
+ s = ".*";
+// console.log("parse of date format, pattern=" + pattern);
+ }
+
+ if(tokens){ tokens.push(match); }
+
+ return "(" + s + ")"; // add capture
+ }).replace(/[\xa0 ]/g, "[\\s\\xa0]"); // normalize whitespace. Need explicit handling of \xa0 for IE.
+}
+
+var _customFormats = [];
+dojo.date.locale.addCustomFormats = function(/*String*/packageName, /*String*/bundleName){
+ // summary:
+ // Add a reference to a bundle containing localized custom formats to be
+ // used by date/time formatting and parsing routines.
+ //
+ // description:
+ // The user may add custom localized formats where the bundle has properties following the
+ // same naming convention used by dojo.cldr: `dateFormat-xxxx` / `timeFormat-xxxx`
+ // The pattern string should match the format used by the CLDR.
+ // See dojo.date.locale.format() for details.
+ // The resources must be loaded by dojo.requireLocalization() prior to use
+
+ _customFormats.push({pkg:packageName,name:bundleName});
+};
+
+dojo.date.locale._getGregorianBundle = function(/*String*/locale){
+ var gregorian = {};
+ dojo.forEach(_customFormats, function(desc){
+ var bundle = dojo.i18n.getLocalization(desc.pkg, desc.name, locale);
+ gregorian = lang.mixin(gregorian, bundle);
+ }, this);
+ return gregorian; /*Object*/
+};
+
+dojo.date.locale.addCustomFormats("dojo.cldr","gregorian");
+
+dojo.date.locale.getNames = function(/*String*/item, /*String*/type, /*String?*/context, /*String?*/locale){
+ // summary:
+ // Used to get localized strings from dojo.cldr for day or month names.
+ //
+ // item:
+ // 'months' || 'days'
+ // type:
+ // 'wide' || 'abbr' || 'narrow' (e.g. "Monday", "Mon", or "M" respectively, in English)
+ // context:
+ // 'standAlone' || 'format' (default)
+ // locale:
+ // override locale used to find the names
+
+ var label,
+ lookup = dojo.date.locale._getGregorianBundle(locale),
+ props = [item, context, type];
+ if(context == 'standAlone'){
+ var key = props.join('-');
+ label = lookup[key];
+ // Fall back to 'format' flavor of name
+ if(label[0] == 1){ label = undefined; } // kludge, in the absence of real aliasing support in dojo.cldr
+ }
+ props[1] = 'format';
+
+ // return by copy so changes won't be made accidentally to the in-memory model
+ return (label || lookup[props.join('-')]).concat(); /*Array*/
+};
+
+dojo.date.locale.isWeekend = function(/*Date?*/dateObject, /*String?*/locale){
+ // summary:
+ // Determines if the date falls on a weekend, according to local custom.
+
+ var weekend = cldr.getWeekend(locale),
+ day = (dateObject || new Date()).getDay();
+ if(weekend.end < weekend.start){
+ weekend.end += 7;
+ if(day < weekend.start){ day += 7; }
+ }
+ return day >= weekend.start && day <= weekend.end; // Boolean
+};
+
+// These are used only by format and strftime. Do they need to be public? Which module should they go in?
+
+dojo.date.locale._getDayOfYear = function(/*Date*/dateObject){
+ // summary: gets the day of the year as represented by dateObject
+ return date.difference(new Date(dateObject.getFullYear(), 0, 1, dateObject.getHours()), dateObject) + 1; // Number
+};
+
+dojo.date.locale._getWeekOfYear = function(/*Date*/dateObject, /*Number*/firstDayOfWeek){
+ if(arguments.length == 1){ firstDayOfWeek = 0; } // Sunday
+
+ var firstDayOfYear = new Date(dateObject.getFullYear(), 0, 1).getDay(),
+ adj = (firstDayOfYear - firstDayOfWeek + 7) % 7,
+ week = Math.floor((dojo.date.locale._getDayOfYear(dateObject) + adj - 1) / 7);
+
+ // if year starts on the specified day, start counting weeks at 1
+ if(firstDayOfYear == firstDayOfWeek){ week++; }
+
+ return week; // Number
+};
+
+return dojo.date.locale;
+});
diff --git a/lib/dojo/date/stamp.js b/lib/dojo/date/stamp.js
index 04b68a06a..029a0130b 100644
--- a/lib/dojo/date/stamp.js
+++ b/lib/dojo/date/stamp.js
@@ -4,147 +4,5 @@
see: http://dojotoolkit.org/license for details
*/
-
-if(!dojo._hasResource["dojo.date.stamp"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojo.date.stamp"] = true;
-dojo.provide("dojo.date.stamp");
-
-dojo.getObject("date.stamp", true, dojo);
-
-// Methods to convert dates to or from a wire (string) format using well-known conventions
-
-dojo.date.stamp.fromISOString = function(/*String*/formattedString, /*Number?*/defaultTime){
- // summary:
- // Returns a Date object given a string formatted according to a subset of the ISO-8601 standard.
- //
- // description:
- // Accepts a string formatted according to a profile of ISO8601 as defined by
- // [RFC3339](http://www.ietf.org/rfc/rfc3339.txt), except that partial input is allowed.
- // Can also process dates as specified [by the W3C](http://www.w3.org/TR/NOTE-datetime)
- // The following combinations are valid:
- //
- // * dates only
- // | * yyyy
- // | * yyyy-MM
- // | * yyyy-MM-dd
- // * times only, with an optional time zone appended
- // | * THH:mm
- // | * THH:mm:ss
- // | * THH:mm:ss.SSS
- // * and "datetimes" which could be any combination of the above
- //
- // timezones may be specified as Z (for UTC) or +/- followed by a time expression HH:mm
- // Assumes the local time zone if not specified. Does not validate. Improperly formatted
- // input may return null. Arguments which are out of bounds will be handled
- // by the Date constructor (e.g. January 32nd typically gets resolved to February 1st)
- // Only years between 100 and 9999 are supported.
- //
- // formattedString:
- // A string such as 2005-06-30T08:05:00-07:00 or 2005-06-30 or T08:05:00
- //
- // defaultTime:
- // Used for defaults for fields omitted in the formattedString.
- // Uses 1970-01-01T00:00:00.0Z by default.
-
- if(!dojo.date.stamp._isoRegExp){
- dojo.date.stamp._isoRegExp =
-//TODO: could be more restrictive and check for 00-59, etc.
- /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(.\d+)?)?((?:[+-](\d{2}):(\d{2}))|Z)?)?$/;
- }
-
- var match = dojo.date.stamp._isoRegExp.exec(formattedString),
- result = null;
-
- if(match){
- match.shift();
- if(match[1]){match[1]--;} // Javascript Date months are 0-based
- if(match[6]){match[6] *= 1000;} // Javascript Date expects fractional seconds as milliseconds
-
- if(defaultTime){
- // mix in defaultTime. Relatively expensive, so use || operators for the fast path of defaultTime === 0
- defaultTime = new Date(defaultTime);
- dojo.forEach(dojo.map(["FullYear", "Month", "Date", "Hours", "Minutes", "Seconds", "Milliseconds"], function(prop){
- return defaultTime["get" + prop]();
- }), function(value, index){
- match[index] = match[index] || value;
- });
- }
- result = new Date(match[0]||1970, match[1]||0, match[2]||1, match[3]||0, match[4]||0, match[5]||0, match[6]||0); //TODO: UTC defaults
- if(match[0] < 100){
- result.setFullYear(match[0] || 1970);
- }
-
- var offset = 0,
- zoneSign = match[7] && match[7].charAt(0);
- if(zoneSign != 'Z'){
- offset = ((match[8] || 0) * 60) + (Number(match[9]) || 0);
- if(zoneSign != '-'){ offset *= -1; }
- }
- if(zoneSign){
- offset -= result.getTimezoneOffset();
- }
- if(offset){
- result.setTime(result.getTime() + offset * 60000);
- }
- }
-
- return result; // Date or null
-};
-
-/*=====
- dojo.date.stamp.__Options = function(){
- // selector: String
- // "date" or "time" for partial formatting of the Date object.
- // Both date and time will be formatted by default.
- // zulu: Boolean
- // if true, UTC/GMT is used for a timezone
- // milliseconds: Boolean
- // if true, output milliseconds
- this.selector = selector;
- this.zulu = zulu;
- this.milliseconds = milliseconds;
- }
-=====*/
-
-dojo.date.stamp.toISOString = function(/*Date*/dateObject, /*dojo.date.stamp.__Options?*/options){
- // summary:
- // Format a Date object as a string according a subset of the ISO-8601 standard
- //
- // description:
- // When options.selector is omitted, output follows [RFC3339](http://www.ietf.org/rfc/rfc3339.txt)
- // The local time zone is included as an offset from GMT, except when selector=='time' (time without a date)
- // Does not check bounds. Only years between 100 and 9999 are supported.
- //
- // dateObject:
- // A Date object
-
- var _ = function(n){ return (n < 10) ? "0" + n : n; };
- options = options || {};
- var formattedDate = [],
- getter = options.zulu ? "getUTC" : "get",
- date = "";
- if(options.selector != "time"){
- var year = dateObject[getter+"FullYear"]();
- date = ["0000".substr((year+"").length)+year, _(dateObject[getter+"Month"]()+1), _(dateObject[getter+"Date"]())].join('-');
- }
- formattedDate.push(date);
- if(options.selector != "date"){
- var time = [_(dateObject[getter+"Hours"]()), _(dateObject[getter+"Minutes"]()), _(dateObject[getter+"Seconds"]())].join(':');
- var millis = dateObject[getter+"Milliseconds"]();
- if(options.milliseconds){
- time += "."+ (millis < 100 ? "0" : "") + _(millis);
- }
- if(options.zulu){
- time += "Z";
- }else if(options.selector != "time"){
- var timezoneOffset = dateObject.getTimezoneOffset();
- var absOffset = Math.abs(timezoneOffset);
- time += (timezoneOffset > 0 ? "-" : "+") +
- _(Math.floor(absOffset/60)) + ":" + _(absOffset%60);
- }
- formattedDate.push(time);
- }
- return formattedDate.join('T'); // String
-};
-
-}
+//>>built
+define("dojo/date/stamp",["../_base/kernel","../_base/lang","../_base/array"],function(_1,_2,_3){_2.getObject("date.stamp",true,_1);_1.date.stamp.fromISOString=function(_4,_5){if(!_1.date.stamp._isoRegExp){_1.date.stamp._isoRegExp=/^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(.\d+)?)?((?:[+-](\d{2}):(\d{2}))|Z)?)?$/;}var _6=_1.date.stamp._isoRegExp.exec(_4),_7=null;if(_6){_6.shift();if(_6[1]){_6[1]--;}if(_6[6]){_6[6]*=1000;}if(_5){_5=new Date(_5);_3.forEach(_3.map(["FullYear","Month","Date","Hours","Minutes","Seconds","Milliseconds"],function(_8){return _5["get"+_8]();}),function(_9,_a){_6[_a]=_6[_a]||_9;});}_7=new Date(_6[0]||1970,_6[1]||0,_6[2]||1,_6[3]||0,_6[4]||0,_6[5]||0,_6[6]||0);if(_6[0]<100){_7.setFullYear(_6[0]||1970);}var _b=0,_c=_6[7]&&_6[7].charAt(0);if(_c!="Z"){_b=((_6[8]||0)*60)+(Number(_6[9])||0);if(_c!="-"){_b*=-1;}}if(_c){_b-=_7.getTimezoneOffset();}if(_b){_7.setTime(_7.getTime()+_b*60000);}}return _7;};_1.date.stamp.toISOString=function(_d,_e){var _f=function(n){return (n<10)?"0"+n:n;};_e=_e||{};var _10=[],_11=_e.zulu?"getUTC":"get",_12="";if(_e.selector!="time"){var _13=_d[_11+"FullYear"]();_12=["0000".substr((_13+"").length)+_13,_f(_d[_11+"Month"]()+1),_f(_d[_11+"Date"]())].join("-");}_10.push(_12);if(_e.selector!="date"){var _14=[_f(_d[_11+"Hours"]()),_f(_d[_11+"Minutes"]()),_f(_d[_11+"Seconds"]())].join(":");var _15=_d[_11+"Milliseconds"]();if(_e.milliseconds){_14+="."+(_15<100?"0":"")+_f(_15);}if(_e.zulu){_14+="Z";}else{if(_e.selector!="time"){var _16=_d.getTimezoneOffset();var _17=Math.abs(_16);_14+=(_16>0?"-":"+")+_f(Math.floor(_17/60))+":"+_f(_17%60);}}_10.push(_14);}return _10.join("T");};return _1.date.stamp;}); \ No newline at end of file
diff --git a/lib/dojo/date/stamp.js.uncompressed.js b/lib/dojo/date/stamp.js.uncompressed.js
new file mode 100644
index 000000000..44b0ab787
--- /dev/null
+++ b/lib/dojo/date/stamp.js.uncompressed.js
@@ -0,0 +1,146 @@
+define("dojo/date/stamp", ["../_base/kernel", "../_base/lang", "../_base/array"], function(dojo, lang, array) {
+ // module:
+ // dojo/date/stamp
+ // summary:
+ // TODOC
+
+lang.getObject("date.stamp", true, dojo);
+
+// Methods to convert dates to or from a wire (string) format using well-known conventions
+
+dojo.date.stamp.fromISOString = function(/*String*/formattedString, /*Number?*/defaultTime){
+ // summary:
+ // Returns a Date object given a string formatted according to a subset of the ISO-8601 standard.
+ //
+ // description:
+ // Accepts a string formatted according to a profile of ISO8601 as defined by
+ // [RFC3339](http://www.ietf.org/rfc/rfc3339.txt), except that partial input is allowed.
+ // Can also process dates as specified [by the W3C](http://www.w3.org/TR/NOTE-datetime)
+ // The following combinations are valid:
+ //
+ // * dates only
+ // | * yyyy
+ // | * yyyy-MM
+ // | * yyyy-MM-dd
+ // * times only, with an optional time zone appended
+ // | * THH:mm
+ // | * THH:mm:ss
+ // | * THH:mm:ss.SSS
+ // * and "datetimes" which could be any combination of the above
+ //
+ // timezones may be specified as Z (for UTC) or +/- followed by a time expression HH:mm
+ // Assumes the local time zone if not specified. Does not validate. Improperly formatted
+ // input may return null. Arguments which are out of bounds will be handled
+ // by the Date constructor (e.g. January 32nd typically gets resolved to February 1st)
+ // Only years between 100 and 9999 are supported.
+ //
+ // formattedString:
+ // A string such as 2005-06-30T08:05:00-07:00 or 2005-06-30 or T08:05:00
+ //
+ // defaultTime:
+ // Used for defaults for fields omitted in the formattedString.
+ // Uses 1970-01-01T00:00:00.0Z by default.
+
+ if(!dojo.date.stamp._isoRegExp){
+ dojo.date.stamp._isoRegExp =
+//TODO: could be more restrictive and check for 00-59, etc.
+ /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(.\d+)?)?((?:[+-](\d{2}):(\d{2}))|Z)?)?$/;
+ }
+
+ var match = dojo.date.stamp._isoRegExp.exec(formattedString),
+ result = null;
+
+ if(match){
+ match.shift();
+ if(match[1]){match[1]--;} // Javascript Date months are 0-based
+ if(match[6]){match[6] *= 1000;} // Javascript Date expects fractional seconds as milliseconds
+
+ if(defaultTime){
+ // mix in defaultTime. Relatively expensive, so use || operators for the fast path of defaultTime === 0
+ defaultTime = new Date(defaultTime);
+ array.forEach(array.map(["FullYear", "Month", "Date", "Hours", "Minutes", "Seconds", "Milliseconds"], function(prop){
+ return defaultTime["get" + prop]();
+ }), function(value, index){
+ match[index] = match[index] || value;
+ });
+ }
+ result = new Date(match[0]||1970, match[1]||0, match[2]||1, match[3]||0, match[4]||0, match[5]||0, match[6]||0); //TODO: UTC defaults
+ if(match[0] < 100){
+ result.setFullYear(match[0] || 1970);
+ }
+
+ var offset = 0,
+ zoneSign = match[7] && match[7].charAt(0);
+ if(zoneSign != 'Z'){
+ offset = ((match[8] || 0) * 60) + (Number(match[9]) || 0);
+ if(zoneSign != '-'){ offset *= -1; }
+ }
+ if(zoneSign){
+ offset -= result.getTimezoneOffset();
+ }
+ if(offset){
+ result.setTime(result.getTime() + offset * 60000);
+ }
+ }
+
+ return result; // Date or null
+};
+
+/*=====
+ dojo.date.stamp.__Options = function(){
+ // selector: String
+ // "date" or "time" for partial formatting of the Date object.
+ // Both date and time will be formatted by default.
+ // zulu: Boolean
+ // if true, UTC/GMT is used for a timezone
+ // milliseconds: Boolean
+ // if true, output milliseconds
+ this.selector = selector;
+ this.zulu = zulu;
+ this.milliseconds = milliseconds;
+ }
+=====*/
+
+dojo.date.stamp.toISOString = function(/*Date*/dateObject, /*dojo.date.stamp.__Options?*/options){
+ // summary:
+ // Format a Date object as a string according a subset of the ISO-8601 standard
+ //
+ // description:
+ // When options.selector is omitted, output follows [RFC3339](http://www.ietf.org/rfc/rfc3339.txt)
+ // The local time zone is included as an offset from GMT, except when selector=='time' (time without a date)
+ // Does not check bounds. Only years between 100 and 9999 are supported.
+ //
+ // dateObject:
+ // A Date object
+
+ var _ = function(n){ return (n < 10) ? "0" + n : n; };
+ options = options || {};
+ var formattedDate = [],
+ getter = options.zulu ? "getUTC" : "get",
+ date = "";
+ if(options.selector != "time"){
+ var year = dateObject[getter+"FullYear"]();
+ date = ["0000".substr((year+"").length)+year, _(dateObject[getter+"Month"]()+1), _(dateObject[getter+"Date"]())].join('-');
+ }
+ formattedDate.push(date);
+ if(options.selector != "date"){
+ var time = [_(dateObject[getter+"Hours"]()), _(dateObject[getter+"Minutes"]()), _(dateObject[getter+"Seconds"]())].join(':');
+ var millis = dateObject[getter+"Milliseconds"]();
+ if(options.milliseconds){
+ time += "."+ (millis < 100 ? "0" : "") + _(millis);
+ }
+ if(options.zulu){
+ time += "Z";
+ }else if(options.selector != "time"){
+ var timezoneOffset = dateObject.getTimezoneOffset();
+ var absOffset = Math.abs(timezoneOffset);
+ time += (timezoneOffset > 0 ? "-" : "+") +
+ _(Math.floor(absOffset/60)) + ":" + _(absOffset%60);
+ }
+ formattedDate.push(time);
+ }
+ return formattedDate.join('T'); // String
+};
+
+return dojo.date.stamp;
+});