From 0610773db746e2390468c06501646b1481ab7182 Mon Sep 17 00:00:00 2001 From: "dslomov@chromium.org" Date: Thu, 10 Oct 2013 19:43:05 +0000 Subject: [PATCH] Revert "Fixing timezone issues with date-time/parse-* tests." This reverts commit r17148 for breaking tests on Windows. TBR=cira@google.com,titzer@chromium.org Review URL: https://codereview.chromium.org/26467005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17149 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/i18n.js | 6 ++-- test/intl/date-format/parse-MMMdy.js | 15 ++++----- test/intl/date-format/parse-mdy.js | 32 +++++++++--------- test/intl/date-format/parse-mdyhms.js | 22 +++++-------- .../{timezone-name.js => utils.js} | 33 +++++-------------- test/intl/testcfg.py | 1 + 6 files changed, 41 insertions(+), 68 deletions(-) rename test/intl/date-format/{timezone-name.js => utils.js} (66%) diff --git a/src/i18n.js b/src/i18n.js index aac440ea59..a80fd4d9b4 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -1367,7 +1367,7 @@ function toLDMLString(options) { ldmlString += appendToLDMLString(option, {'2-digit': 'ss', 'numeric': 's'}); option = getOption('timeZoneName', 'string', ['short', 'long']); - ldmlString += appendToLDMLString(option, {short: 'z', long: 'zzzz'}); + ldmlString += appendToLDMLString(option, {short: 'v', long: 'vv'}); return ldmlString; } @@ -1440,9 +1440,9 @@ function fromLDMLString(ldmlString) { options = appendToDateTimeObject( options, 'second', match, {s: 'numeric', ss: '2-digit'}); - match = ldmlString.match(/z|zzzz/g); + match = ldmlString.match(/v{1,2}/g); options = appendToDateTimeObject( - options, 'timeZoneName', match, {z: 'short', zzzz: 'long'}); + options, 'timeZoneName', match, {v: 'short', vv: 'long'}); return options; } diff --git a/test/intl/date-format/parse-MMMdy.js b/test/intl/date-format/parse-MMMdy.js index 73ee586733..7136527810 100644 --- a/test/intl/date-format/parse-MMMdy.js +++ b/test/intl/date-format/parse-MMMdy.js @@ -30,22 +30,19 @@ var dtf = new Intl.DateTimeFormat(['en'], {year: 'numeric', month: 'short', - day: 'numeric', - timeZone: 'America/Los_Angeles'}); + day: 'numeric'}); // Make sure we have pattern we expect (may change in the future). assertEquals('MMM d, y', dtf.resolved.pattern); -var date = dtf.v8Parse('Feb 4, 1974'); -assertEquals(1974, date.getFullYear()); -assertEquals(1, date.getMonth()); -assertEquals(4, date.getDate()); +assertEquals('Sat May 04 1974 00:00:00 GMT-0007 (PDT)', + usePDT(String(dtf.v8Parse('May 4, 1974')))); // Missing , in the pattern. -assertEquals(undefined, dtf.v8Parse('Feb 4 1974')); +assertEquals(undefined, dtf.v8Parse('May 4 1974')); // Extra "th" after 4 in the pattern. -assertEquals(undefined, dtf.v8Parse('Feb 4th, 1974')); +assertEquals(undefined, dtf.v8Parse('May 4th, 1974')); // Wrong pattern. -assertEquals(undefined, dtf.v8Parse('2/4/1974')); +assertEquals(undefined, dtf.v8Parse('5/4/1974')); diff --git a/test/intl/date-format/parse-mdy.js b/test/intl/date-format/parse-mdy.js index 788a7bbd08..e767a0b2d2 100644 --- a/test/intl/date-format/parse-mdy.js +++ b/test/intl/date-format/parse-mdy.js @@ -27,25 +27,23 @@ // Testing v8Parse method for date only. -function checkDate(date) { - assertEquals(1974, date.getFullYear()); - assertEquals(1, date.getMonth()); - assertEquals(4, date.getDate()); -} - -var dtf = new Intl.DateTimeFormat(['en'], {timeZone: 'America/Los_Angeles'}); +var dtf = new Intl.DateTimeFormat(['en']); // Make sure we have pattern we expect (may change in the future). assertEquals('M/d/y', dtf.resolved.pattern); -checkDate(dtf.v8Parse('2/4/74')); -checkDate(dtf.v8Parse('02/04/74')); -checkDate(dtf.v8Parse('2/04/74')); -checkDate(dtf.v8Parse('02/4/74')); -checkDate(dtf.v8Parse('2/4/1974')); -checkDate(dtf.v8Parse('02/4/1974')); -checkDate(dtf.v8Parse('2/04/1974')); -checkDate(dtf.v8Parse('02/04/1974')); +assertEquals('Sat May 04 1974 00:00:00 GMT-0007 (PDT)', + usePDT(String(dtf.v8Parse('5/4/74')))); +assertEquals('Sat May 04 1974 00:00:00 GMT-0007 (PDT)', + usePDT(String(dtf.v8Parse('05/04/74')))); +assertEquals('Sat May 04 1974 00:00:00 GMT-0007 (PDT)', + usePDT(String(dtf.v8Parse('5/04/74')))); +assertEquals('Sat May 04 1974 00:00:00 GMT-0007 (PDT)', + usePDT(String(dtf.v8Parse('5/4/1974')))); -// Month is numeric, so it fails on "Feb". -assertEquals(undefined, dtf.v8Parse('Feb 4th 1974')); +// Month is numeric, so it fails on "May". +assertEquals(undefined, dtf.v8Parse('May 4th 1974')); + +// Time is ignored from the input, since the pattern doesn't have it. +assertEquals('Sat May 04 1974 00:00:00 GMT-0007 (PDT)', + usePDT(String(dtf.v8Parse('5/4/74 12:30:12')))); diff --git a/test/intl/date-format/parse-mdyhms.js b/test/intl/date-format/parse-mdyhms.js index 73efb62053..74f7467f3d 100644 --- a/test/intl/date-format/parse-mdyhms.js +++ b/test/intl/date-format/parse-mdyhms.js @@ -30,28 +30,22 @@ var dtf = new Intl.DateTimeFormat(['en'], {year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', - minute: 'numeric', second: 'numeric', - timeZone: 'UTC'}); + minute: 'numeric', second: 'numeric'}); // Make sure we have pattern we expect (may change in the future). assertEquals('M/d/y h:mm:ss a', dtf.resolved.pattern); -var date = dtf.v8Parse('2/4/74 12:30:42 pm'); -assertEquals(1974, date.getUTCFullYear()); -assertEquals(1, date.getUTCMonth()); -assertEquals(4, date.getUTCDate()); -assertEquals(12, date.getUTCHours()); -assertEquals(30, date.getUTCMinutes()); -assertEquals(42, date.getUTCSeconds()); +assertEquals('Sat May 04 1974 12:30:12 GMT-0007 (PDT)', + usePDT(String(dtf.v8Parse('5/4/74 12:30:12 pm')))); // AM/PM were not specified. -assertEquals(undefined, dtf.v8Parse('2/4/74 12:30:12')); +assertEquals(undefined, dtf.v8Parse('5/4/74 12:30:12')); // Time was not specified. -assertEquals(undefined, dtf.v8Parse('2/4/74')); +assertEquals(undefined, dtf.v8Parse('5/4/74')); -// Month is numeric, so it fails on "Feb". -assertEquals(undefined, dtf.v8Parse('Feb 4th 1974')); +// Month is numeric, so it fails on "May". +assertEquals(undefined, dtf.v8Parse('May 4th 1974')); // Wrong date delimiter. -assertEquals(undefined, dtf.v8Parse('2-4-74 12:30:12 am')); +assertEquals(undefined, dtf.v8Parse('5-4-74 12:30:12 am')); diff --git a/test/intl/date-format/timezone-name.js b/test/intl/date-format/utils.js similarity index 66% rename from test/intl/date-format/timezone-name.js rename to test/intl/date-format/utils.js index 2ed5c1acae..535de15e9a 100644 --- a/test/intl/date-format/timezone-name.js +++ b/test/intl/date-format/utils.js @@ -25,29 +25,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Tests time zone names. +// Utility methods for date testing. -// Winter date (PST). -var winter = new Date(2013, 1, 12, 14, 42, 53, 0); - -// Summer date (PDT). -var summer = new Date(2013, 7, 12, 14, 42, 53, 0); - -// Common flags for both formatters. -var flags = { - year: 'numeric', month: 'long', day: 'numeric', - hour : '2-digit', minute : '2-digit', second : '2-digit', - timeZone: 'America/Los_Angeles' -}; - -flags.timeZoneName = "short"; -var dfs = new Intl.DateTimeFormat('en-US', flags); - -assertTrue(dfs.format(winter).indexOf('PST') !== -1); -assertTrue(dfs.format(summer).indexOf('PDT') !== -1); - -flags.timeZoneName = "long"; -var dfl = new Intl.DateTimeFormat('en-US', flags); - -assertTrue(dfl.format(winter).indexOf('Pacific Standard Time') !== -1); -assertTrue(dfl.format(summer).indexOf('Pacific Daylight Time') !== -1); +/** + * Returns date with timezone info forced into PDT. + */ +function usePDT(dateString) { + var removedTZ = dateString.replace(/(\+|-)\d{4}/, '-0007'); + return removedTZ.replace(/\(.*?\)/, '(PDT)'); +} diff --git a/test/intl/testcfg.py b/test/intl/testcfg.py index 9fc087e5f5..09d29d0bee 100644 --- a/test/intl/testcfg.py +++ b/test/intl/testcfg.py @@ -57,6 +57,7 @@ class IntlTestSuite(testsuite.TestSuite): files = [] files.append(os.path.join(self.root, "assert.js")) files.append(os.path.join(self.root, "utils.js")) + files.append(os.path.join(self.root, "date-format", "utils.js")) files.append(os.path.join(self.root, testcase.path + self.suffix())) flags += files