From a0f3c963a50aa67d618154c2399ddd2465b774f0 Mon Sep 17 00:00:00 2001 From: "Ramalingam Kandaswamy,Manikandan" Date: Fri, 10 Feb 2017 14:09:44 -0800 Subject: [PATCH] Date: Olson-timezone-support (real 'z') --- src/date.js | 3 +- src/date/format-properties.js | 56 ++- src/date/format.js | 19 +- src/date/timezone-region-format.js | 25 ++ test/functional/date/date-formatter.js | 10 +- test/unit/date/format.js | 571 +++++++++++++------------ 6 files changed, 410 insertions(+), 274 deletions(-) create mode 100644 src/date/timezone-region-format.js diff --git a/src/date.js b/src/date.js index 98500c9fa..7757487e9 100644 --- a/src/date.js +++ b/src/date.js @@ -51,7 +51,7 @@ function validateRequiredCldr( path, value ) { */ Globalize.dateFormatter = Globalize.prototype.dateFormatter = function( options ) { - var args, cldr, numberFormatters, pad, pattern, properties, returnFn; + var args, cldr, numberFormatters, pad, pattern, properties, returnFn, timeZone; validateParameterTypePlainObject( options, "options" ); @@ -66,6 +66,7 @@ Globalize.prototype.dateFormatter = function( options ) { pattern = dateExpandPattern( options, cldr ); properties = dateFormatProperties( pattern, cldr ); cldr.off( "get", validateRequiredCldr ); + properties.timeZone = timeZone;//TODO validate // Create needed number formatters. numberFormatters = properties.numberFormatters; diff --git a/src/date/format-properties.js b/src/date/format-properties.js index 6c42a9db5..d189bb8be 100644 --- a/src/date/format-properties.js +++ b/src/date/format-properties.js @@ -19,11 +19,12 @@ define([ * * TODO Support other calendar types. */ -return function( pattern, cldr ) { +return function( pattern, cldr, timeZone ) { var properties = { numberFormatters: {}, pattern: pattern, - timeSeparator: numberSymbol( "timeSeparator", cldr ) + timeSeparator: numberSymbol( "timeSeparator", cldr ), + timeZone: timeZone }, widths = [ "abbreviated", "wide", "narrow" ]; @@ -208,6 +209,57 @@ return function( pattern, cldr ) { // Zone case "z": + + // z...zzz: "{shortRegion}", eg. "PST" or "PDT". + // zzzz: "{regionName} {Standard Time}" or "{regionName} {Daylight Time}", + // eg. "Pacific Standard Time" or "Pacific Daylight Time". + if ( properties.timeZone ) { + + // The latest metazone data of the metazone array. + //TODO expand to support the historic metazones based on the given date. + var standardTzName, + daylightTzName, + metaZone = cldr.supplemental([ + "metaZones/metazoneInfo/timezone", properties.timeZone, 0 + ]); + + if ( metaZone ) { + standardTzName = cldr.main([ + "dates/timeZoneNames/metazone", + metaZone.usesMetazone._mzone, + length < 4 ? "short" : "long", + "standard" + ]); + daylightTzName = cldr.main([ + "dates/timeZoneNames/metazone", + metaZone.usesMetazone._mzone, + length < 4 ? "short" : "long", + "daylight" + ]); + if ( !standardTzName && !daylightTzName ) { + var exemplarCity = cldr.main( + "dates/timeZoneNames/zone/", + properties.timeZone, + "/exemplarCity" + ); + standardTzName = cldr.main( + "dates/timeZoneNames/regionFormat-type-standard" + ) + .replace( /\{0\}/, exemplarCity ); + + daylightTzName = cldr.main( + "dates/timeZoneNames/regionFormat-type-daylight" + ) + .replace( /\{0\}/, exemplarCity ); + } + if ( standardTzName && daylightTzName ) { + properties.standardTzName = standardTzName; + properties.daylightTzName = daylightTzName; + break; + } + } + } + /* falls through */ case "O": // O: "{gmtFormat}+H;{gmtFormat}-H" or "{gmtZeroFormat}", eg. "GMT-8" or "GMT". diff --git a/src/date/format.js b/src/date/format.js index 0bb4834d3..e62c0d665 100644 --- a/src/date/format.js +++ b/src/date/format.js @@ -5,10 +5,11 @@ define([ "./pattern-re", "./start-of", "./timezone-hour-format", + "./timezone-region-format", "./week-days", "../util/remove-literal-quotes" ], function( dateDayOfWeek, dateDayOfYear, dateMillisecondsInDay, datePatternRe, dateStartOf, - dateTimezoneHourFormat, dateWeekDays, removeLiteralQuotes ) { + dateTimezoneHourFormat, dateTimezoneRegionFormat, dateWeekDays, removeLiteralQuotes ) { /** * format( date, properties ) @@ -207,6 +208,22 @@ return function( date, numberFormatters, properties ) { // Zone case "z": + + // z...zzz: "{shortRegion}", eg. "PST" or "PDT". + // zzzz: "{regionName} {Standard Time}" or "{regionName} {Daylight Time}", + // eg. "Pacific Standard Time" or "Pacific Daylight Time". + if ( properties.timeZone ) { + ret = dateTimezoneRegionFormat( + date, + properties.standardTzName, + properties.daylightTzName + ); + if ( ret ) { + break; + } + } + + /* falls through */ case "O": // O: "{gmtFormat}+H;{gmtFormat}-H" or "{gmtZeroFormat}", eg. "GMT-8" or "GMT". diff --git a/src/date/timezone-region-format.js b/src/date/timezone-region-format.js new file mode 100644 index 000000000..457d831d7 --- /dev/null +++ b/src/date/timezone-region-format.js @@ -0,0 +1,25 @@ +define([], function() { + +/** + * regionFormat( date, format, timeZoneId, formatNumber ) + * + * Return date's timezone names according to the format passed. + * Eg for format when timezone offset is 180: + * "regionFormat": "{0} Time", + * "regionFormat-type-standard": "{0} Standard Time", + * "regionFormat-type-daylight": "{0} Daylight Time", + * "fallbackFormat": "{1} ({0})", + */ +return function( date, standardTzName, daylightTzName ) { + + // var isDST = date.isDST(); FIXME + var isDST = false, + format; + if ( isDST ) { + format = daylightTzName; + } else { + format = standardTzName; + } + return format; +}; +}); diff --git a/test/functional/date/date-formatter.js b/test/functional/date/date-formatter.js index a62937e9a..5899244b0 100644 --- a/test/functional/date/date-formatter.js +++ b/test/functional/date/date-formatter.js @@ -105,7 +105,8 @@ QUnit.test( "should allow for runtime compilation", function( assert ) { "pm-alt-variant": "pm" }, "pattern": "h:mm:ss a", - "timeSeparator": ":" + "timeSeparator": ":", + "timeZone": undefined }); } ); @@ -120,6 +121,7 @@ QUnit.test( "should allow for runtime compilation", function( assert ) { assert.deepEqual( runtimeArgs[ 1 ], { "pattern": "EEEE, MMMM d, y", "timeSeparator": ":", + "timeZone": undefined, "days": { "E": { "4": { @@ -214,7 +216,8 @@ QUnit.test( "should allow for runtime compilation", function( assert ) { } }, "pattern": "E, MMM d, y G, h:mm:ss a", - "timeSeparator": ":" + "timeSeparator": ":", + "timeZone": undefined }); } ); @@ -246,7 +249,8 @@ QUnit.test( "should allow for runtime compilation", function( assert ) { } }, "pattern": "LLL", - "timeSeparator": ":" + "timeSeparator": ":", + "timeZone": undefined }); } ); diff --git a/test/unit/date/format.js b/test/unit/date/format.js index 9c586a693..3a1e1de0b 100644 --- a/test/unit/date/format.js +++ b/test/unit/date/format.js @@ -13,12 +13,13 @@ define([ "json!cldr-data/supplemental/likelySubtags.json", "json!cldr-data/supplemental/timeData.json", "json!cldr-data/supplemental/weekData.json", + "json!cldr-data/supplemental/metaZones.json", "cldr/event", "cldr/supplemental" ], function( Cldr, format, formatProperties, stringPad, deCaGregorian, enCaGregorian, enTimeZoneNames, enGbCaGregorian, enInCaGregorian, ptCaGregorian, ruCaGregorian, likelySubtags, - timeData, weekData ) { + timeData, weekData, metaZones ) { var cldr, year0 = new Date( -62167190400000 ), @@ -26,7 +27,8 @@ var cldr, date1 = new Date( 1982, 0, 2, 9, 5, 59 ), date2 = new Date( 2010, 8, 15, 17, 35, 7, 369 ), date3 = new Date( 1981, 11, 31, 12 ), // thu - date4 = new Date( 1994, 11, 31, 12 ); // sat + date4 = new Date( 1994, 11, 31, 12 ), + defaultTimezone; // sat function FakeDate( timezoneOffset ) { this.timezoneOffset = timezoneOffset; @@ -52,15 +54,16 @@ Cldr.load( ptCaGregorian, ruCaGregorian, timeData, - weekData + weekData, + metaZones ); cldr = new Cldr( "en" ); -QUnit.assert.dateFormat = function( date, pattern, cldr, expected ) { +QUnit.assert.dateFormat = function( date, pattern, timeZone, cldr, expected ) { var pad, numberFormatters = [], - properties = formatProperties( pattern, cldr ); + properties = formatProperties( pattern, cldr, timeZone ); // Create simple number formatters for this test purposes. for ( pad in properties.numberFormatters ) { @@ -77,27 +80,27 @@ QUnit.module( "Date Format" ); */ QUnit.test( "should format era (G|GG|GGG)", function( assert ) { - assert.dateFormat( date1, "G", cldr, "AD" ); - assert.dateFormat( year0, "G", cldr, "AD" ); - assert.dateFormat( yearBc, "G", cldr, "BC" ); - assert.dateFormat( date1, "GG", cldr, "AD" ); - assert.dateFormat( year0, "GG", cldr, "AD" ); - assert.dateFormat( yearBc, "GG", cldr, "BC" ); - assert.dateFormat( date1, "GGG", cldr, "AD" ); - assert.dateFormat( year0, "GGG", cldr, "AD" ); - assert.dateFormat( yearBc, "GGG", cldr, "BC" ); + assert.dateFormat( date1, "G", defaultTimezone, cldr, "AD" ); + assert.dateFormat( year0, "G", defaultTimezone, cldr, "AD" ); + assert.dateFormat( yearBc, "G", defaultTimezone, cldr, "BC" ); + assert.dateFormat( date1, "GG", defaultTimezone, cldr, "AD" ); + assert.dateFormat( year0, "GG", defaultTimezone, cldr, "AD" ); + assert.dateFormat( yearBc, "GG", defaultTimezone, cldr, "BC" ); + assert.dateFormat( date1, "GGG", defaultTimezone, cldr, "AD" ); + assert.dateFormat( year0, "GGG", defaultTimezone, cldr, "AD" ); + assert.dateFormat( yearBc, "GGG", defaultTimezone, cldr, "BC" ); }); QUnit.test( "should format era (GGGG)", function( assert ) { - assert.dateFormat( date1, "GGGG", cldr, "Anno Domini" ); - assert.dateFormat( year0, "GGGG", cldr, "Anno Domini" ); - assert.dateFormat( yearBc, "GGGG", cldr, "Before Christ" ); + assert.dateFormat( date1, "GGGG", defaultTimezone, cldr, "Anno Domini" ); + assert.dateFormat( year0, "GGGG", defaultTimezone, cldr, "Anno Domini" ); + assert.dateFormat( yearBc, "GGGG", defaultTimezone, cldr, "Before Christ" ); }); QUnit.test( "should format era (GGGGG)", function( assert ) { - assert.dateFormat( date1, "GGGGG", cldr, "A" ); - assert.dateFormat( year0, "GGGGG", cldr, "A" ); - assert.dateFormat( yearBc, "GGGGG", cldr, "B" ); + assert.dateFormat( date1, "GGGGG", defaultTimezone, cldr, "A" ); + assert.dateFormat( year0, "GGGGG", defaultTimezone, cldr, "A" ); + assert.dateFormat( yearBc, "GGGGG", defaultTimezone, cldr, "B" ); }); /** @@ -105,40 +108,40 @@ QUnit.test( "should format era (GGGGG)", function( assert ) { */ QUnit.test( "should format year (y) with no padding", function( assert ) { - assert.dateFormat( date2, "y", cldr, "2010" ); - assert.dateFormat( date1, "y", cldr, "1982" ); - assert.dateFormat( year0, "y", cldr, "0" ); + assert.dateFormat( date2, "y", defaultTimezone, cldr, "2010" ); + assert.dateFormat( date1, "y", defaultTimezone, cldr, "1982" ); + assert.dateFormat( year0, "y", defaultTimezone, cldr, "0" ); }); QUnit.test( "should format year (yy) with padding, and limit 2 digits", function( assert ) { - assert.dateFormat( date2, "yy", cldr, "10" ); - assert.dateFormat( date1, "yy", cldr, "82" ); - assert.dateFormat( year0, "yy", cldr, "00" ); + assert.dateFormat( date2, "yy", defaultTimezone, cldr, "10" ); + assert.dateFormat( date1, "yy", defaultTimezone, cldr, "82" ); + assert.dateFormat( year0, "yy", defaultTimezone, cldr, "00" ); }); QUnit.test( "should format year (yyy+) with padding", function( assert ) { - assert.dateFormat( date1, "yyy", cldr, "1982" ); - assert.dateFormat( date2, "yyy", cldr, "2010" ); - assert.dateFormat( year0, "yyyy", cldr, "0000" ); - assert.dateFormat( date1, "yyyyy", cldr, "01982" ); - assert.dateFormat( date2, "yyyyy", cldr, "02010" ); + assert.dateFormat( date1, "yyy", defaultTimezone, cldr, "1982" ); + assert.dateFormat( date2, "yyy", defaultTimezone, cldr, "2010" ); + assert.dateFormat( year0, "yyyy", defaultTimezone, cldr, "0000" ); + assert.dateFormat( date1, "yyyyy", defaultTimezone, cldr, "01982" ); + assert.dateFormat( date2, "yyyyy", defaultTimezone, cldr, "02010" ); }); QUnit.test( "should format year in \"week of year\" (Y) with no padding", function( assert ) { - assert.dateFormat( date3, "Y", cldr, "1982" ); - assert.dateFormat( date4, "Y", cldr, "1994" ); + assert.dateFormat( date3, "Y", defaultTimezone, cldr, "1982" ); + assert.dateFormat( date4, "Y", defaultTimezone, cldr, "1994" ); }); QUnit.test( "should format year in \"week of year\" (YY) with padding, and limit 2 digits", function( assert ) { - assert.dateFormat( date3, "YY", cldr, "82" ); - assert.dateFormat( date4, "YY", cldr, "94" ); + assert.dateFormat( date3, "YY", defaultTimezone, cldr, "82" ); + assert.dateFormat( date4, "YY", defaultTimezone, cldr, "94" ); }); QUnit.test( "should format year in \"week of year\" (YYY+) with padding", function( assert ) { - assert.dateFormat( date3, "YYY", cldr, "1982" ); - assert.dateFormat( date4, "YYY", cldr, "1994" ); - assert.dateFormat( date3, "YYYYY", cldr, "01982" ); - assert.dateFormat( date4, "YYYYY", cldr, "01994" ); + assert.dateFormat( date3, "YYY", defaultTimezone, cldr, "1982" ); + assert.dateFormat( date4, "YYY", defaultTimezone, cldr, "1994" ); + assert.dateFormat( date3, "YYYYY", defaultTimezone, cldr, "01982" ); + assert.dateFormat( date4, "YYYYY", defaultTimezone, cldr, "01994" ); }); /** @@ -146,31 +149,31 @@ QUnit.test( "should format year in \"week of year\" (YYY+) with padding", functi */ QUnit.test( "should format quarter (Q|q) with no padding", function( assert ) { - assert.dateFormat( date1, "Q", cldr, "1" ); - assert.dateFormat( date2, "Q", cldr, "3" ); - assert.dateFormat( date1, "q", cldr, "1" ); - assert.dateFormat( date2, "q", cldr, "3" ); + assert.dateFormat( date1, "Q", defaultTimezone, cldr, "1" ); + assert.dateFormat( date2, "Q", defaultTimezone, cldr, "3" ); + assert.dateFormat( date1, "q", defaultTimezone, cldr, "1" ); + assert.dateFormat( date2, "q", defaultTimezone, cldr, "3" ); }); QUnit.test( "should format quarter (QQ|qq) with padding", function( assert ) { - assert.dateFormat( date1, "QQ", cldr, "01" ); - assert.dateFormat( date2, "QQ", cldr, "03" ); - assert.dateFormat( date1, "qq", cldr, "01" ); - assert.dateFormat( date2, "qq", cldr, "03" ); + assert.dateFormat( date1, "QQ", defaultTimezone, cldr, "01" ); + assert.dateFormat( date2, "QQ", defaultTimezone, cldr, "03" ); + assert.dateFormat( date1, "qq", defaultTimezone, cldr, "01" ); + assert.dateFormat( date2, "qq", defaultTimezone, cldr, "03" ); }); QUnit.test( "should format quarter (QQQ|qqq)", function( assert ) { - assert.dateFormat( date1, "QQQ", cldr, "Q1" ); - assert.dateFormat( date2, "QQQ", cldr, "Q3" ); - assert.dateFormat( date1, "qqq", cldr, "Q1" ); - assert.dateFormat( date2, "qqq", cldr, "Q3" ); + assert.dateFormat( date1, "QQQ", defaultTimezone, cldr, "Q1" ); + assert.dateFormat( date2, "QQQ", defaultTimezone, cldr, "Q3" ); + assert.dateFormat( date1, "qqq", defaultTimezone, cldr, "Q1" ); + assert.dateFormat( date2, "qqq", defaultTimezone, cldr, "Q3" ); }); QUnit.test( "should format quarter (QQQQ|qqqq) with padding", function( assert ) { - assert.dateFormat( date1, "QQQQ", cldr, "1st quarter" ); - assert.dateFormat( date2, "QQQQ", cldr, "3rd quarter" ); - assert.dateFormat( date1, "qqqq", cldr, "1st quarter" ); - assert.dateFormat( date2, "qqqq", cldr, "3rd quarter" ); + assert.dateFormat( date1, "QQQQ", defaultTimezone, cldr, "1st quarter" ); + assert.dateFormat( date2, "QQQQ", defaultTimezone, cldr, "3rd quarter" ); + assert.dateFormat( date1, "qqqq", defaultTimezone, cldr, "1st quarter" ); + assert.dateFormat( date2, "qqqq", defaultTimezone, cldr, "3rd quarter" ); }); /** @@ -178,38 +181,38 @@ QUnit.test( "should format quarter (QQQQ|qqqq) with padding", function( assert ) */ QUnit.test( "should format month (M|L) with no padding", function( assert ) { - assert.dateFormat( date1, "M", cldr, "1" ); - assert.dateFormat( date2, "M", cldr, "9" ); - assert.dateFormat( date1, "L", cldr, "1" ); - assert.dateFormat( date2, "L", cldr, "9" ); + assert.dateFormat( date1, "M", defaultTimezone, cldr, "1" ); + assert.dateFormat( date2, "M", defaultTimezone, cldr, "9" ); + assert.dateFormat( date1, "L", defaultTimezone, cldr, "1" ); + assert.dateFormat( date2, "L", defaultTimezone, cldr, "9" ); }); QUnit.test( "should format month (MM|LL) with padding", function( assert ) { - assert.dateFormat( date1, "MM", cldr, "01" ); - assert.dateFormat( date2, "MM", cldr, "09" ); - assert.dateFormat( date1, "LL", cldr, "01" ); - assert.dateFormat( date2, "LL", cldr, "09" ); + assert.dateFormat( date1, "MM", defaultTimezone, cldr, "01" ); + assert.dateFormat( date2, "MM", defaultTimezone, cldr, "09" ); + assert.dateFormat( date1, "LL", defaultTimezone, cldr, "01" ); + assert.dateFormat( date2, "LL", defaultTimezone, cldr, "09" ); }); QUnit.test( "should format month (MMM|LLL)", function( assert ) { - assert.dateFormat( date1, "MMM", cldr, "Jan" ); - assert.dateFormat( date2, "MMM", cldr, "Sep" ); - assert.dateFormat( date1, "LLL", cldr, "Jan" ); - assert.dateFormat( date2, "LLL", cldr, "Sep" ); + assert.dateFormat( date1, "MMM", defaultTimezone, cldr, "Jan" ); + assert.dateFormat( date2, "MMM", defaultTimezone, cldr, "Sep" ); + assert.dateFormat( date1, "LLL", defaultTimezone, cldr, "Jan" ); + assert.dateFormat( date2, "LLL", defaultTimezone, cldr, "Sep" ); }); QUnit.test( "should format month (MMMM|LLLL)", function( assert ) { - assert.dateFormat( date1, "MMMM", cldr, "January" ); - assert.dateFormat( date2, "MMMM", cldr, "September" ); - assert.dateFormat( date1, "LLLL", cldr, "January" ); - assert.dateFormat( date2, "LLLL", cldr, "September" ); + assert.dateFormat( date1, "MMMM", defaultTimezone, cldr, "January" ); + assert.dateFormat( date2, "MMMM", defaultTimezone, cldr, "September" ); + assert.dateFormat( date1, "LLLL", defaultTimezone, cldr, "January" ); + assert.dateFormat( date2, "LLLL", defaultTimezone, cldr, "September" ); }); QUnit.test( "should format month (MMMMM|LLLLL)", function( assert ) { - assert.dateFormat( date1, "MMMMM", cldr, "J" ); - assert.dateFormat( date2, "MMMMM", cldr, "S" ); - assert.dateFormat( date1, "LLLLL", cldr, "J" ); - assert.dateFormat( date2, "LLLLL", cldr, "S" ); + assert.dateFormat( date1, "MMMMM", defaultTimezone, cldr, "J" ); + assert.dateFormat( date2, "MMMMM", defaultTimezone, cldr, "S" ); + assert.dateFormat( date1, "LLLLL", defaultTimezone, cldr, "J" ); + assert.dateFormat( date2, "LLLLL", defaultTimezone, cldr, "S" ); }); /** @@ -217,19 +220,19 @@ QUnit.test( "should format month (MMMMM|LLLLL)", function( assert ) { */ QUnit.test( "should format week of year (w) with no padding", function( assert ) { - assert.dateFormat( date1, "w", cldr, "1" ); - assert.dateFormat( date2, "w", cldr, "38" ); + assert.dateFormat( date1, "w", defaultTimezone, cldr, "1" ); + assert.dateFormat( date2, "w", defaultTimezone, cldr, "38" ); }); QUnit.test( "should format week of year (ww) with padding", function( assert ) { - assert.dateFormat( date1, "ww", cldr, "01" ); - assert.dateFormat( date2, "ww", cldr, "38" ); + assert.dateFormat( date1, "ww", defaultTimezone, cldr, "01" ); + assert.dateFormat( date2, "ww", defaultTimezone, cldr, "38" ); }); QUnit.test( "should format week of month (W)", function( assert ) { - assert.dateFormat( date1, "W", cldr, "1" ); - assert.dateFormat( date2, "W", cldr, "3" ); - assert.dateFormat( date3, "W", cldr, "5" ); + assert.dateFormat( date1, "W", defaultTimezone, cldr, "1" ); + assert.dateFormat( date2, "W", defaultTimezone, cldr, "3" ); + assert.dateFormat( date3, "W", defaultTimezone, cldr, "5" ); }); /** @@ -237,29 +240,29 @@ QUnit.test( "should format week of month (W)", function( assert ) { */ QUnit.test( "should format day (d) with no padding", function( assert ) { - assert.dateFormat( date1, "d", cldr, "2" ); - assert.dateFormat( date2, "d", cldr, "15" ); + assert.dateFormat( date1, "d", defaultTimezone, cldr, "2" ); + assert.dateFormat( date2, "d", defaultTimezone, cldr, "15" ); }); QUnit.test( "should format day (dd) with padding", function( assert ) { - assert.dateFormat( date1, "dd", cldr, "02" ); - assert.dateFormat( date2, "dd", cldr, "15" ); + assert.dateFormat( date1, "dd", defaultTimezone, cldr, "02" ); + assert.dateFormat( date2, "dd", defaultTimezone, cldr, "15" ); }); QUnit.test( "should format day of year (D) with no padding", function( assert ) { - assert.dateFormat( date1, "D", cldr, "2" ); - assert.dateFormat( date2, "D", cldr, "258" ); + assert.dateFormat( date1, "D", defaultTimezone, cldr, "2" ); + assert.dateFormat( date2, "D", defaultTimezone, cldr, "258" ); }); QUnit.test( "should format day of year (DD|DDD) with padding", function( assert ) { - assert.dateFormat( date1, "DD", cldr, "02" ); - assert.dateFormat( date1, "DDD", cldr, "002" ); - assert.dateFormat( date2, "DD", cldr, "258" ); + assert.dateFormat( date1, "DD", defaultTimezone, cldr, "02" ); + assert.dateFormat( date1, "DDD", defaultTimezone, cldr, "002" ); + assert.dateFormat( date2, "DD", defaultTimezone, cldr, "258" ); }); QUnit.test( "should format day of week in month (F)", function( assert ) { - assert.dateFormat( date1, "F", cldr, "1" ); - assert.dateFormat( date2, "F", cldr, "3" ); + assert.dateFormat( date1, "F", defaultTimezone, cldr, "1" ); + assert.dateFormat( date2, "F", defaultTimezone, cldr, "3" ); }); /** @@ -267,57 +270,57 @@ QUnit.test( "should format day of week in month (F)", function( assert ) { */ QUnit.test( "should format local day of week (e|c) with no padding", function( assert ) { - assert.dateFormat( date1, "e", cldr, "7" ); - assert.dateFormat( date2, "e", cldr, "4" ); - assert.dateFormat( date1, "c", cldr, "7" ); - assert.dateFormat( date2, "c", cldr, "4" ); + assert.dateFormat( date1, "e", defaultTimezone, cldr, "7" ); + assert.dateFormat( date2, "e", defaultTimezone, cldr, "4" ); + assert.dateFormat( date1, "c", defaultTimezone, cldr, "7" ); + assert.dateFormat( date2, "c", defaultTimezone, cldr, "4" ); }); QUnit.test( "should format local day of week (ee|cc) with padding", function( assert ) { - assert.dateFormat( date1, "ee", cldr, "07" ); - assert.dateFormat( date2, "ee", cldr, "04" ); - assert.dateFormat( date1, "cc", cldr, "07" ); - assert.dateFormat( date2, "cc", cldr, "04" ); + assert.dateFormat( date1, "ee", defaultTimezone, cldr, "07" ); + assert.dateFormat( date2, "ee", defaultTimezone, cldr, "04" ); + assert.dateFormat( date1, "cc", defaultTimezone, cldr, "07" ); + assert.dateFormat( date2, "cc", defaultTimezone, cldr, "04" ); }); QUnit.test( "should format local day of week (E|EE|EEE|eee|ccc)", function( assert ) { - assert.dateFormat( date1, "E", cldr, "Sat" ); - assert.dateFormat( date2, "E", cldr, "Wed" ); - assert.dateFormat( date1, "EE", cldr, "Sat" ); - assert.dateFormat( date2, "EE", cldr, "Wed" ); - assert.dateFormat( date1, "EEE", cldr, "Sat" ); - assert.dateFormat( date2, "EEE", cldr, "Wed" ); - assert.dateFormat( date1, "eee", cldr, "Sat" ); - assert.dateFormat( date2, "eee", cldr, "Wed" ); - assert.dateFormat( date1, "ccc", cldr, "Sat" ); - assert.dateFormat( date2, "ccc", cldr, "Wed" ); + assert.dateFormat( date1, "E", defaultTimezone, cldr, "Sat" ); + assert.dateFormat( date2, "E", defaultTimezone, cldr, "Wed" ); + assert.dateFormat( date1, "EE", defaultTimezone, cldr, "Sat" ); + assert.dateFormat( date2, "EE", defaultTimezone, cldr, "Wed" ); + assert.dateFormat( date1, "EEE", defaultTimezone, cldr, "Sat" ); + assert.dateFormat( date2, "EEE", defaultTimezone, cldr, "Wed" ); + assert.dateFormat( date1, "eee", defaultTimezone, cldr, "Sat" ); + assert.dateFormat( date2, "eee", defaultTimezone, cldr, "Wed" ); + assert.dateFormat( date1, "ccc", defaultTimezone, cldr, "Sat" ); + assert.dateFormat( date2, "ccc", defaultTimezone, cldr, "Wed" ); }); QUnit.test( "should format local day of week (EEEE|eeee|cccc)", function( assert ) { - assert.dateFormat( date1, "EEEE", cldr, "Saturday" ); - assert.dateFormat( date2, "EEEE", cldr, "Wednesday" ); - assert.dateFormat( date1, "eeee", cldr, "Saturday" ); - assert.dateFormat( date2, "eeee", cldr, "Wednesday" ); - assert.dateFormat( date1, "cccc", cldr, "Saturday" ); - assert.dateFormat( date2, "cccc", cldr, "Wednesday" ); + assert.dateFormat( date1, "EEEE", defaultTimezone, cldr, "Saturday" ); + assert.dateFormat( date2, "EEEE", defaultTimezone, cldr, "Wednesday" ); + assert.dateFormat( date1, "eeee", defaultTimezone, cldr, "Saturday" ); + assert.dateFormat( date2, "eeee", defaultTimezone, cldr, "Wednesday" ); + assert.dateFormat( date1, "cccc", defaultTimezone, cldr, "Saturday" ); + assert.dateFormat( date2, "cccc", defaultTimezone, cldr, "Wednesday" ); }); QUnit.test( "should format local day of week (EEEEE|eeeee|ccccc)", function( assert ) { - assert.dateFormat( date1, "EEEEE", cldr, "S" ); - assert.dateFormat( date2, "EEEEE", cldr, "W" ); - assert.dateFormat( date1, "eeeee", cldr, "S" ); - assert.dateFormat( date2, "eeeee", cldr, "W" ); - assert.dateFormat( date1, "ccccc", cldr, "S" ); - assert.dateFormat( date2, "ccccc", cldr, "W" ); + assert.dateFormat( date1, "EEEEE", defaultTimezone, cldr, "S" ); + assert.dateFormat( date2, "EEEEE", defaultTimezone, cldr, "W" ); + assert.dateFormat( date1, "eeeee", defaultTimezone, cldr, "S" ); + assert.dateFormat( date2, "eeeee", defaultTimezone, cldr, "W" ); + assert.dateFormat( date1, "ccccc", defaultTimezone, cldr, "S" ); + assert.dateFormat( date2, "ccccc", defaultTimezone, cldr, "W" ); }); QUnit.test( "should format local day of week (EEEEEE|eeeeee|cccccc)", function( assert ) { - assert.dateFormat( date1, "EEEEEE", cldr, "Sa" ); - assert.dateFormat( date2, "EEEEEE", cldr, "We" ); - assert.dateFormat( date1, "eeeeee", cldr, "Sa" ); - assert.dateFormat( date2, "eeeeee", cldr, "We" ); - assert.dateFormat( date1, "cccccc", cldr, "Sa" ); - assert.dateFormat( date2, "cccccc", cldr, "We" ); + assert.dateFormat( date1, "EEEEEE", defaultTimezone, cldr, "Sa" ); + assert.dateFormat( date2, "EEEEEE", defaultTimezone, cldr, "We" ); + assert.dateFormat( date1, "eeeeee", defaultTimezone, cldr, "Sa" ); + assert.dateFormat( date2, "eeeeee", defaultTimezone, cldr, "We" ); + assert.dateFormat( date1, "cccccc", defaultTimezone, cldr, "Sa" ); + assert.dateFormat( date2, "cccccc", defaultTimezone, cldr, "We" ); }); /** @@ -325,8 +328,8 @@ QUnit.test( "should format local day of week (EEEEEE|eeeeee|cccccc)", function( */ QUnit.test( "should format period (a)", function( assert ) { - assert.dateFormat( date1, "a", cldr, "AM" ); - assert.dateFormat( date2, "a", cldr, "PM" ); + assert.dateFormat( date1, "a", defaultTimezone, cldr, "AM" ); + assert.dateFormat( date2, "a", defaultTimezone, cldr, "PM" ); }); /** @@ -334,66 +337,66 @@ QUnit.test( "should format period (a)", function( assert ) { */ QUnit.test( "should format hour (h) using 12-hour-cycle [1-12] with no padding", function( assert ) { - assert.dateFormat( date1, "h", cldr, "9" ); - assert.dateFormat( date2, "h", cldr, "5" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "h", cldr, "12" ); + assert.dateFormat( date1, "h", defaultTimezone, cldr, "9" ); + assert.dateFormat( date2, "h", defaultTimezone, cldr, "5" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "h", defaultTimezone, cldr, "12" ); }); QUnit.test( "should format hour (hh) using 12-hour-cycle [1-12] with padding", function( assert ) { - assert.dateFormat( date1, "hh", cldr, "09" ); - assert.dateFormat( date2, "hh", cldr, "05" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "hh", cldr, "12" ); + assert.dateFormat( date1, "hh", defaultTimezone, cldr, "09" ); + assert.dateFormat( date2, "hh", defaultTimezone, cldr, "05" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "hh", defaultTimezone, cldr, "12" ); }); QUnit.test( "should format hour (H) using 24-hour-cycle [0-23] with no padding", function( assert ) { - assert.dateFormat( date1, "H", cldr, "9" ); - assert.dateFormat( date2, "H", cldr, "17" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "H", cldr, "0" ); + assert.dateFormat( date1, "H", defaultTimezone, cldr, "9" ); + assert.dateFormat( date2, "H", defaultTimezone, cldr, "17" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "H", defaultTimezone, cldr, "0" ); }); QUnit.test( "should format hour (HH) using 24-hour-cycle [0-23] with padding", function( assert ) { - assert.dateFormat( date1, "HH", cldr, "09" ); - assert.dateFormat( date2, "HH", cldr, "17" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "HH", cldr, "00" ); + assert.dateFormat( date1, "HH", defaultTimezone, cldr, "09" ); + assert.dateFormat( date2, "HH", defaultTimezone, cldr, "17" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "HH", defaultTimezone, cldr, "00" ); }); QUnit.test( "should format hour (K) using 12-hour-cycle [0-11] with no padding", function( assert ) { - assert.dateFormat( date1, "K", cldr, "9" ); - assert.dateFormat( date2, "K", cldr, "5" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "K", cldr, "0" ); + assert.dateFormat( date1, "K", defaultTimezone, cldr, "9" ); + assert.dateFormat( date2, "K", defaultTimezone, cldr, "5" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "K", defaultTimezone, cldr, "0" ); }); QUnit.test( "should format hour (KK) using 12-hour-cycle [0-11] with padding", function( assert ) { - assert.dateFormat( date1, "KK", cldr, "09" ); - assert.dateFormat( date2, "KK", cldr, "05" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "KK", cldr, "00" ); + assert.dateFormat( date1, "KK", defaultTimezone, cldr, "09" ); + assert.dateFormat( date2, "KK", defaultTimezone, cldr, "05" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "KK", defaultTimezone, cldr, "00" ); }); QUnit.test( "should format hour (k) using 24-hour-cycle [1-24] with no padding", function( assert ) { - assert.dateFormat( date1, "k", cldr, "9" ); - assert.dateFormat( date2, "k", cldr, "17" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "k", cldr, "24" ); + assert.dateFormat( date1, "k", defaultTimezone, cldr, "9" ); + assert.dateFormat( date2, "k", defaultTimezone, cldr, "17" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "k", defaultTimezone, cldr, "24" ); }); QUnit.test( "should format hour (kk) using 24-hour-cycle [1-24] with padding", function( assert ) { - assert.dateFormat( date1, "kk", cldr, "09" ); - assert.dateFormat( date2, "kk", cldr, "17" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "kk", cldr, "24" ); + assert.dateFormat( date1, "kk", defaultTimezone, cldr, "09" ); + assert.dateFormat( date2, "kk", defaultTimezone, cldr, "17" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "kk", defaultTimezone, cldr, "24" ); }); QUnit.test( "should format hour (j) using preferred hour format for the locale (h, H, K, or k) with no padding", function( assert ) { - assert.dateFormat( date2, "j", cldr, "5" ); - assert.dateFormat( date2, "j", new Cldr( "pt-BR" ), "17" ); - assert.dateFormat( date2, "j", new Cldr( "de" ), "17" ); - assert.dateFormat( date2, "j", new Cldr( "en-IN" ), "5" ); - assert.dateFormat( date2, "j", new Cldr( "en-GB" ), "17" ); - assert.dateFormat( date2, "j", new Cldr( "ru" ), "17" ); + assert.dateFormat( date2, "j", defaultTimezone, cldr, "5" ); + assert.dateFormat( date2, "j", defaultTimezone, new Cldr( "pt-BR" ), "17" ); + assert.dateFormat( date2, "j", defaultTimezone, new Cldr( "de" ), "17" ); + assert.dateFormat( date2, "j", defaultTimezone, new Cldr( "en-IN" ), "5" ); + assert.dateFormat( date2, "j", defaultTimezone, new Cldr( "en-GB" ), "17" ); + assert.dateFormat( date2, "j", defaultTimezone, new Cldr( "ru" ), "17" ); }); QUnit.test( "should format hour (jj) using preferred hour format for the locale (h, H, K, or k) with padding", function( assert ) { - assert.dateFormat( date1, "jj", cldr, "09" ); - assert.dateFormat( date2, "jj", cldr, "05" ); - assert.dateFormat( new Date( 0, 0, 0, 0 ), "jj", cldr, "12" ); + assert.dateFormat( date1, "jj", defaultTimezone, cldr, "09" ); + assert.dateFormat( date2, "jj", defaultTimezone, cldr, "05" ); + assert.dateFormat( new Date( 0, 0, 0, 0 ), "jj", defaultTimezone, cldr, "12" ); }); /** @@ -401,13 +404,13 @@ QUnit.test( "should format hour (jj) using preferred hour format for the locale */ QUnit.test( "should format minute (m) with no padding", function( assert ) { - assert.dateFormat( date1, "m", cldr, "5" ); - assert.dateFormat( date2, "m", cldr, "35" ); + assert.dateFormat( date1, "m", defaultTimezone, cldr, "5" ); + assert.dateFormat( date2, "m", defaultTimezone, cldr, "35" ); }); QUnit.test( "should format minute (mm) with padding", function( assert ) { - assert.dateFormat( date1, "mm", cldr, "05" ); - assert.dateFormat( date2, "mm", cldr, "35" ); + assert.dateFormat( date1, "mm", defaultTimezone, cldr, "05" ); + assert.dateFormat( date2, "mm", defaultTimezone, cldr, "35" ); }); /** @@ -415,170 +418,204 @@ QUnit.test( "should format minute (mm) with padding", function( assert ) { */ QUnit.test( "should format second (s) with no padding", function( assert ) { - assert.dateFormat( date1, "s", cldr, "59" ); - assert.dateFormat( date2, "s", cldr, "7" ); + assert.dateFormat( date1, "s", defaultTimezone, cldr, "59" ); + assert.dateFormat( date2, "s", defaultTimezone, cldr, "7" ); }); QUnit.test( "should format second (ss) with padding", function( assert ) { - assert.dateFormat( date1, "ss", cldr, "59" ); - assert.dateFormat( date2, "ss", cldr, "07" ); + assert.dateFormat( date1, "ss", defaultTimezone, cldr, "59" ); + assert.dateFormat( date2, "ss", defaultTimezone, cldr, "07" ); }); QUnit.test( "should format various milliseconds (S+)", function( assert ) { - assert.dateFormat( date2, "S", cldr, "4" ); - assert.dateFormat( date2, "SS", cldr, "37" ); - assert.dateFormat( date2, "SSS", cldr, "369" ); - assert.dateFormat( date2, "SSSS", cldr, "3690" ); - assert.dateFormat( date2, "SSSSS", cldr, "36900" ); + assert.dateFormat( date2, "S", defaultTimezone, cldr, "4" ); + assert.dateFormat( date2, "SS", defaultTimezone, cldr, "37" ); + assert.dateFormat( date2, "SSS", defaultTimezone, cldr, "369" ); + assert.dateFormat( date2, "SSSS", defaultTimezone, cldr, "3690" ); + assert.dateFormat( date2, "SSSSS", defaultTimezone, cldr, "36900" ); }); QUnit.test( "should format various milliseconds (A+)", function( assert ) { - assert.dateFormat( date2, "A", cldr, "633074" ); - assert.dateFormat( date2, "AA", cldr, "6330737" ); - assert.dateFormat( date2, "AAA", cldr, "63307369" ); - assert.dateFormat( date2, "AAAA", cldr, "633073690" ); - assert.dateFormat( date2, "AAAAA", cldr, "6330736900" ); + assert.dateFormat( date2, "A", defaultTimezone, cldr, "633074" ); + assert.dateFormat( date2, "AA", defaultTimezone, cldr, "6330737" ); + assert.dateFormat( date2, "AAA", defaultTimezone, cldr, "63307369" ); + assert.dateFormat( date2, "AAAA", defaultTimezone, cldr, "633073690" ); + assert.dateFormat( date2, "AAAAA", defaultTimezone, cldr, "6330736900" ); }); /** * Zone */ +QUnit.test( "should format timezone (z)", function( assert ) { + var date = new Date(); + assert.dateFormat(date, "z", "America/Los_Angeles", cldr, "PST"); + assert.dateFormat(date, "zz", "America/Los_Angeles", cldr, "PST"); + assert.dateFormat(date, "zzz", "America/Los_Angeles", cldr, "PST"); + assert.dateFormat(date, "zzzz", "America/Los_Angeles", cldr, "Pacific Standard Time"); + + //fall through to 'O' format + date = new FakeDate( 0 ); + assert.dateFormat(date, "z", "Etc/GMT", cldr, "GMT"); + assert.dateFormat(date, "zz", "Etc/GMT", cldr, "GMT"); + assert.dateFormat(date, "zzz", "Etc/GMT", cldr, "GMT"); + assert.dateFormat(date, "zzzz", "Etc/GMT", cldr, "GMT"); +}); QUnit.test( "should format timezone (z)", function( assert ) { var date = new FakeDate( 0 ); - assert.dateFormat( date, "z", cldr, "GMT" ); - assert.dateFormat( date, "zz", cldr, "GMT" ); - assert.dateFormat( date, "zzz", cldr, "GMT" ); - assert.dateFormat( date, "zzzz", cldr, "GMT" ); + assert.dateFormat( date, "z", defaultTimezone, cldr, "GMT" ); + assert.dateFormat( date, "zz", defaultTimezone, cldr, "GMT" ); + assert.dateFormat( date, "zzz", defaultTimezone, cldr, "GMT" ); + assert.dateFormat( date, "zzzz", defaultTimezone, cldr, "GMT" ); + + date = new FakeDate( -3 ); + assert.dateFormat( date, "z", defaultTimezone, cldr, "GMT-3" ); + assert.dateFormat( date, "zz", defaultTimezone, cldr, "GMT-3" ); + assert.dateFormat( date, "zzz", defaultTimezone, cldr, "GMT-3" ); + assert.dateFormat( date, "zzzz", defaultTimezone, cldr, "GMT-03:00" ); + + date = new FakeDate( 11 ); + assert.dateFormat( date, "z", defaultTimezone, cldr, "GMT+11" ); + assert.dateFormat( date, "zz", defaultTimezone, cldr, "GMT+11" ); + assert.dateFormat( date, "zzz", defaultTimezone, cldr, "GMT+11" ); + assert.dateFormat( date, "zzzz", defaultTimezone, cldr, "GMT+11:00" ); +}); + +QUnit.test( "should format timezone (O)", function( assert ) { + var date = new FakeDate( 0 ); + assert.dateFormat( date, "O", defaultTimezone, cldr, "GMT" ); + assert.dateFormat( date, "OO", defaultTimezone, cldr, "GMT" ); + assert.dateFormat( date, "OOO", defaultTimezone, cldr, "GMT" ); + assert.dateFormat( date, "OOOO", defaultTimezone, cldr, "GMT" ); date = new FakeDate( -3 ); - assert.dateFormat( date, "z", cldr, "GMT-3" ); - assert.dateFormat( date, "zz", cldr, "GMT-3" ); - assert.dateFormat( date, "zzz", cldr, "GMT-3" ); - assert.dateFormat( date, "zzzz", cldr, "GMT-03:00" ); + assert.dateFormat( date, "O", defaultTimezone, cldr, "GMT-3" ); + assert.dateFormat( date, "OO", defaultTimezone, cldr, "GMT-3" ); + assert.dateFormat( date, "OOO", defaultTimezone, cldr, "GMT-3" ); + assert.dateFormat( date, "OOOO", defaultTimezone, cldr, "GMT-03:00" ); date = new FakeDate( 11 ); - assert.dateFormat( date, "z", cldr, "GMT+11" ); - assert.dateFormat( date, "zz", cldr, "GMT+11" ); - assert.dateFormat( date, "zzz", cldr, "GMT+11" ); - assert.dateFormat( date, "zzzz", cldr, "GMT+11:00" ); + assert.dateFormat( date, "O", defaultTimezone, cldr, "GMT+11" ); + assert.dateFormat( date, "OO", defaultTimezone, cldr, "GMT+11" ); + assert.dateFormat( date, "OOO", defaultTimezone, cldr, "GMT+11" ); + assert.dateFormat( date, "OOOO", defaultTimezone, cldr, "GMT+11:00" ); }); QUnit.test( "should format timezone (Z)", function( assert ) { var date = new FakeDate( 0 ); - assert.dateFormat( date, "Z", cldr, "+0000" ); - assert.dateFormat( date, "ZZ", cldr, "+0000" ); - assert.dateFormat( date, "ZZZ", cldr, "+0000" ); - assert.dateFormat( date, "ZZZZ", cldr, "GMT" ); - assert.dateFormat( date, "ZZZZZ", cldr, "Z" ); + assert.dateFormat( date, "Z", defaultTimezone, cldr, "+0000" ); + assert.dateFormat( date, "ZZ", defaultTimezone, cldr, "+0000" ); + assert.dateFormat( date, "ZZZ", defaultTimezone, cldr, "+0000" ); + assert.dateFormat( date, "ZZZZ", defaultTimezone, cldr, "GMT" ); + assert.dateFormat( date, "ZZZZZ", defaultTimezone, cldr, "Z" ); date = new FakeDate( -3 ); - assert.dateFormat( date, "Z", cldr, "-0300" ); - assert.dateFormat( date, "ZZ", cldr, "-0300" ); - assert.dateFormat( date, "ZZZ", cldr, "-0300" ); - assert.dateFormat( date, "ZZZZ", cldr, "GMT-03:00" ); - assert.dateFormat( date, "ZZZZZ", cldr, "-03:00" ); + assert.dateFormat( date, "Z", defaultTimezone, cldr, "-0300" ); + assert.dateFormat( date, "ZZ", defaultTimezone, cldr, "-0300" ); + assert.dateFormat( date, "ZZZ", defaultTimezone, cldr, "-0300" ); + assert.dateFormat( date, "ZZZZ", defaultTimezone, cldr, "GMT-03:00" ); + assert.dateFormat( date, "ZZZZZ", defaultTimezone, cldr, "-03:00" ); date = new FakeDate( 11 ); - assert.dateFormat( date, "Z", cldr, "+1100" ); - assert.dateFormat( date, "ZZ", cldr, "+1100" ); - assert.dateFormat( date, "ZZZ", cldr, "+1100" ); - assert.dateFormat( date, "ZZZZ", cldr, "GMT+11:00" ); - assert.dateFormat( date, "ZZZZZ", cldr, "+11:00" ); + assert.dateFormat( date, "Z", defaultTimezone, cldr, "+1100" ); + assert.dateFormat( date, "ZZ", defaultTimezone, cldr, "+1100" ); + assert.dateFormat( date, "ZZZ", defaultTimezone, cldr, "+1100" ); + assert.dateFormat( date, "ZZZZ", defaultTimezone, cldr, "GMT+11:00" ); + assert.dateFormat( date, "ZZZZZ", defaultTimezone, cldr, "+11:00" ); }); QUnit.test( "should format timezone (O)", function( assert ) { var date = new FakeDate( 0 ); - assert.dateFormat( date, "O", cldr, "GMT" ); - assert.dateFormat( date, "OOOO", cldr, "GMT" ); + assert.dateFormat( date, "O", defaultTimezone, cldr, "GMT" ); + assert.dateFormat( date, "OOOO", defaultTimezone, cldr, "GMT" ); date = new FakeDate( -3 ); - assert.dateFormat( date, "O", cldr, "GMT-3" ); - assert.dateFormat( date, "OOOO", cldr, "GMT-03:00" ); + assert.dateFormat( date, "O", defaultTimezone, cldr, "GMT-3" ); + assert.dateFormat( date, "OOOO", defaultTimezone, cldr, "GMT-03:00" ); date = new FakeDate( 11 ); - assert.dateFormat( date, "O", cldr, "GMT+11" ); - assert.dateFormat( date, "OOOO", cldr, "GMT+11:00" ); + assert.dateFormat( date, "O", defaultTimezone, cldr, "GMT+11" ); + assert.dateFormat( date, "OOOO", defaultTimezone, cldr, "GMT+11:00" ); }); QUnit.test( "should format timezone (X)", function( assert ) { var date = new FakeDate( 0 ); - assert.dateFormat( date, "X", cldr, "Z" ); - assert.dateFormat( date, "XX", cldr, "Z" ); - assert.dateFormat( date, "XXX", cldr, "Z" ); - assert.dateFormat( date, "XXXX", cldr, "Z" ); - assert.dateFormat( date, "XXXXX", cldr, "Z" ); + assert.dateFormat( date, "X", defaultTimezone, cldr, "Z" ); + assert.dateFormat( date, "XX", defaultTimezone, cldr, "Z" ); + assert.dateFormat( date, "XXX", defaultTimezone, cldr, "Z" ); + assert.dateFormat( date, "XXXX", defaultTimezone, cldr, "Z" ); + assert.dateFormat( date, "XXXXX", defaultTimezone, cldr, "Z" ); date = new FakeDate( -3 ); - assert.dateFormat( date, "X", cldr, "-03" ); - assert.dateFormat( date, "XX", cldr, "-0300" ); - assert.dateFormat( date, "XXX", cldr, "-03:00" ); - assert.dateFormat( date, "XXXX", cldr, "-0300" ); - assert.dateFormat( date, "XXXXX", cldr, "-03:00" ); + assert.dateFormat( date, "X", defaultTimezone, cldr, "-03" ); + assert.dateFormat( date, "XX", defaultTimezone, cldr, "-0300" ); + assert.dateFormat( date, "XXX", defaultTimezone, cldr, "-03:00" ); + assert.dateFormat( date, "XXXX", defaultTimezone, cldr, "-0300" ); + assert.dateFormat( date, "XXXXX", defaultTimezone, cldr, "-03:00" ); // TODO (see https://github.com/jquery/globalize/issues/339) // date = new FakeDate( -7.883 ); - // assert.dateFormat( date, "X", cldr, "-0752" ); - // assert.dateFormat( date, "XX", cldr, "-0752" ); - // assert.dateFormat( date, "XXX", cldr, "-07:52" ); - // assert.dateFormat( date, "XXXX", cldr, "-075258" ); - // assert.dateFormat( date, "XXXXX", cldr, "-07:52:58" ); + // assert.dateFormat( date, "X", defaultTimezone, cldr, "-0752" ); + // assert.dateFormat( date, "XX", defaultTimezone, cldr, "-0752" ); + // assert.dateFormat( date, "XXX", defaultTimezone, cldr, "-07:52" ); + // assert.dateFormat( date, "XXXX", defaultTimezone, cldr, "-075258" ); + // assert.dateFormat( date, "XXXXX", defaultTimezone, cldr, "-07:52:58" ); date = new FakeDate( 5.5 ); // TODO (see https://github.com/jquery/globalize/issues/339) - // assert.dateFormat( date, "X", cldr, "+0530" ); - assert.dateFormat( date, "XX", cldr, "+0530" ); - assert.dateFormat( date, "XXX", cldr, "+05:30" ); - assert.dateFormat( date, "XXXX", cldr, "+0530" ); - assert.dateFormat( date, "XXXXX", cldr, "+05:30" ); + // assert.dateFormat( date, "X", defaultTimezone, cldr, "+0530" ); + assert.dateFormat( date, "XX", defaultTimezone, cldr, "+0530" ); + assert.dateFormat( date, "XXX", defaultTimezone, cldr, "+05:30" ); + assert.dateFormat( date, "XXXX", defaultTimezone, cldr, "+0530" ); + assert.dateFormat( date, "XXXXX", defaultTimezone, cldr, "+05:30" ); date = new FakeDate( 11 ); - assert.dateFormat( date, "X", cldr, "+11" ); - assert.dateFormat( date, "XX", cldr, "+1100" ); - assert.dateFormat( date, "XXX", cldr, "+11:00" ); - assert.dateFormat( date, "XXXX", cldr, "+1100" ); - assert.dateFormat( date, "XXXXX", cldr, "+11:00" ); + assert.dateFormat( date, "X", defaultTimezone, cldr, "+11" ); + assert.dateFormat( date, "XX", defaultTimezone, cldr, "+1100" ); + assert.dateFormat( date, "XXX", defaultTimezone, cldr, "+11:00" ); + assert.dateFormat( date, "XXXX", defaultTimezone, cldr, "+1100" ); + assert.dateFormat( date, "XXXXX", defaultTimezone, cldr, "+11:00" ); }); QUnit.test( "should format timezone (x)", function( assert ) { var date = new FakeDate( 0 ); - assert.dateFormat( date, "x", cldr, "+00" ); - assert.dateFormat( date, "xx", cldr, "+0000" ); - assert.dateFormat( date, "xxx", cldr, "+00:00" ); - assert.dateFormat( date, "xxxx", cldr, "+0000" ); - assert.dateFormat( date, "xxxxx", cldr, "+00:00" ); + assert.dateFormat( date, "x", defaultTimezone, cldr, "+00" ); + assert.dateFormat( date, "xx", defaultTimezone, cldr, "+0000" ); + assert.dateFormat( date, "xxx", defaultTimezone, cldr, "+00:00" ); + assert.dateFormat( date, "xxxx", defaultTimezone, cldr, "+0000" ); + assert.dateFormat( date, "xxxxx", defaultTimezone, cldr, "+00:00" ); date = new FakeDate( -3 ); - assert.dateFormat( date, "x", cldr, "-03" ); - assert.dateFormat( date, "xx", cldr, "-0300" ); - assert.dateFormat( date, "xxx", cldr, "-03:00" ); - assert.dateFormat( date, "xxxx", cldr, "-0300" ); - assert.dateFormat( date, "xxxxx", cldr, "-03:00" ); + assert.dateFormat( date, "x", defaultTimezone, cldr, "-03" ); + assert.dateFormat( date, "xx", defaultTimezone, cldr, "-0300" ); + assert.dateFormat( date, "xxx", defaultTimezone, cldr, "-03:00" ); + assert.dateFormat( date, "xxxx", defaultTimezone, cldr, "-0300" ); + assert.dateFormat( date, "xxxxx", defaultTimezone, cldr, "-03:00" ); // TODO (see https://github.com/jquery/globalize/issues/339) // date = new FakeDate( -7.883 ); - // assert.dateFormat( date, "x", cldr, "-0752" ); - // assert.dateFormat( date, "xx", cldr, "-0752" ); - // assert.dateFormat( date, "xxx", cldr, "-07:52" ); - // assert.dateFormat( date, "xxxx", cldr, "-075258" ); - // assert.dateFormat( date, "xxxxx", cldr, "-07:52:58" ); + // assert.dateFormat( date, "x", defaultTimezone, cldr, "-0752" ); + // assert.dateFormat( date, "xx", defaultTimezone, cldr, "-0752" ); + // assert.dateFormat( date, "xxx", defaultTimezone, cldr, "-07:52" ); + // assert.dateFormat( date, "xxxx", defaultTimezone, cldr, "-075258" ); + // assert.dateFormat( date, "xxxxx", defaultTimezone, cldr, "-07:52:58" ); date = new FakeDate( 5.5 ); // TODO (see https://github.com/jquery/globalize/issues/339) - // assert.dateFormat( date, "x", cldr, "+0530" ); - assert.dateFormat( date, "xx", cldr, "+0530" ); - assert.dateFormat( date, "xxx", cldr, "+05:30" ); - assert.dateFormat( date, "xxxx", cldr, "+0530" ); - assert.dateFormat( date, "xxxxx", cldr, "+05:30" ); + // assert.dateFormat( date, "x", defaultTimezone, cldr, "+0530" ); + assert.dateFormat( date, "xx", defaultTimezone, cldr, "+0530" ); + assert.dateFormat( date, "xxx", defaultTimezone, cldr, "+05:30" ); + assert.dateFormat( date, "xxxx", defaultTimezone, cldr, "+0530" ); + assert.dateFormat( date, "xxxxx", defaultTimezone, cldr, "+05:30" ); date = new FakeDate( 11 ); - assert.dateFormat( date, "x", cldr, "+11" ); - assert.dateFormat( date, "xx", cldr, "+1100" ); - assert.dateFormat( date, "xxx", cldr, "+11:00" ); - assert.dateFormat( date, "xxxx", cldr, "+1100" ); - assert.dateFormat( date, "xxxxx", cldr, "+11:00" ); + assert.dateFormat( date, "x", defaultTimezone, cldr, "+11" ); + assert.dateFormat( date, "xx", defaultTimezone, cldr, "+1100" ); + assert.dateFormat( date, "xxx", defaultTimezone, cldr, "+11:00" ); + assert.dateFormat( date, "xxxx", defaultTimezone, cldr, "+1100" ); + assert.dateFormat( date, "xxxxx", defaultTimezone, cldr, "+11:00" ); }); /** @@ -586,8 +623,8 @@ QUnit.test( "should format timezone (x)", function( assert ) { */ QUnit.test( "should format literal (')", function( assert ) { - assert.dateFormat( date1, "yyyy.MM.dd G 'at' HH:mm:ss", cldr, "1982.01.02 AD at 09:05:59" ); - assert.dateFormat( date1, "hh 'o''clock' a", cldr, "09 o'clock AM" ); + assert.dateFormat( date1, "yyyy.MM.dd G 'at' HH:mm:ss", defaultTimezone, cldr, "1982.01.02 AD at 09:05:59" ); + assert.dateFormat( date1, "hh 'o''clock' a", defaultTimezone, cldr, "09 o'clock AM" ); }); });