Revision: 17171
Author:   [email protected]
Date:     Fri Oct 11 17:54:31 2013 UTC
Log:      Original review https://codereview.chromium.org/25855005.

Reverting reverted r17148 and fixing build (test) breakage by side stepping the Windows vs. Linux issue of different Date object for the same millisecond time stamp.
We do that by using UTC Date methods (they eliminate DST problems).

Windows:
new Date(129193200000);
Sun Feb 03 1974 23:00:00 GMT-0800 (Pacific Standard Time)

Linux:
new Date(129193200000);
Mon Feb 04 1974 00:00:00 GMT-0700 (PST)

BUG=2919
[email protected], [email protected]

Review URL: https://codereview.chromium.org/26918002
http://code.google.com/p/v8/source/detail?r=17171

Added:
 /branches/bleeding_edge/test/intl/date-format/timezone-name.js
Deleted:
 /branches/bleeding_edge/test/intl/date-format/utils.js
Modified:
 /branches/bleeding_edge/src/i18n.js
 /branches/bleeding_edge/test/intl/date-format/parse-MMMdy.js
 /branches/bleeding_edge/test/intl/date-format/parse-mdy.js
 /branches/bleeding_edge/test/intl/date-format/parse-mdyhms.js
 /branches/bleeding_edge/test/intl/testcfg.py

=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/intl/date-format/timezone-name.js Fri Oct 11 17:54:31 2013 UTC
@@ -0,0 +1,53 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (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.
+
+// 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);
=======================================
--- /branches/bleeding_edge/test/intl/date-format/utils.js Thu Oct 10 19:43:05 2013 UTC
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2013 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-//       notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-//       copyright notice, this list of conditions and the following
-//       disclaimer in the documentation and/or other materials provided
-//       with the distribution.
-//     * Neither the name of Google Inc. nor the names of its
-//       contributors may be used to endorse or promote products derived
-//       from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Utility methods for date testing.
-
-/**
- * Returns date with timezone info forced into PDT.
- */
-function usePDT(dateString) {
-  var removedTZ = dateString.replace(/(\+|-)\d{4}/, '-0007');
-  return removedTZ.replace(/\(.*?\)/, '(PDT)');
-}
=======================================
--- /branches/bleeding_edge/src/i18n.js Thu Oct 10 19:43:05 2013 UTC
+++ /branches/bleeding_edge/src/i18n.js Fri Oct 11 17:54:31 2013 UTC
@@ -1367,7 +1367,7 @@
ldmlString += appendToLDMLString(option, {'2-digit': 'ss', 'numeric': 's'});

   option = getOption('timeZoneName', 'string', ['short', 'long']);
-  ldmlString += appendToLDMLString(option, {short: 'v', long: 'vv'});
+  ldmlString += appendToLDMLString(option, {short: 'z', long: 'zzzz'});

   return ldmlString;
 }
@@ -1440,9 +1440,9 @@
   options = appendToDateTimeObject(
       options, 'second', match, {s: 'numeric', ss: '2-digit'});

-  match = ldmlString.match(/v{1,2}/g);
+  match = ldmlString.match(/z|zzzz/g);
   options = appendToDateTimeObject(
-      options, 'timeZoneName', match, {v: 'short', vv: 'long'});
+      options, 'timeZoneName', match, {z: 'short', zzzz: 'long'});

   return options;
 }
=======================================
--- /branches/bleeding_edge/test/intl/date-format/parse-MMMdy.js Thu Oct 10 19:43:05 2013 UTC +++ /branches/bleeding_edge/test/intl/date-format/parse-MMMdy.js Fri Oct 11 17:54:31 2013 UTC
@@ -30,19 +30,22 @@

 var dtf = new Intl.DateTimeFormat(['en'],
                                   {year: 'numeric', month: 'short',
-                                   day: 'numeric'});
+                                   day: 'numeric',
+                                   timeZone: 'America/Los_Angeles'});

 // Make sure we have pattern we expect (may change in the future).
 assertEquals('MMM d, y', dtf.resolved.pattern);

-assertEquals('Sat May 04 1974 00:00:00 GMT-0007 (PDT)',
-             usePDT(String(dtf.v8Parse('May 4, 1974'))));
+var date = dtf.v8Parse('Feb 4, 1974');
+assertEquals(1974, date.getUTCFullYear());
+assertEquals(1, date.getUTCMonth());
+assertEquals(4, date.getUTCDate());

 // Missing , in the pattern.
-assertEquals(undefined, dtf.v8Parse('May 4 1974'));
+assertEquals(undefined, dtf.v8Parse('Feb 4 1974'));

 // Extra "th" after 4 in the pattern.
-assertEquals(undefined, dtf.v8Parse('May 4th, 1974'));
+assertEquals(undefined, dtf.v8Parse('Feb 4th, 1974'));

 // Wrong pattern.
-assertEquals(undefined, dtf.v8Parse('5/4/1974'));
+assertEquals(undefined, dtf.v8Parse('2/4/1974'));
=======================================
--- /branches/bleeding_edge/test/intl/date-format/parse-mdy.js Thu Oct 10 19:43:05 2013 UTC +++ /branches/bleeding_edge/test/intl/date-format/parse-mdy.js Fri Oct 11 17:54:31 2013 UTC
@@ -27,23 +27,25 @@

 // Testing v8Parse method for date only.

-var dtf = new Intl.DateTimeFormat(['en']);
+function checkDate(date) {
+  assertEquals(1974, date.getUTCFullYear());
+  assertEquals(1, date.getUTCMonth());
+  assertEquals(4, date.getUTCDate());
+}
+
+var dtf = new Intl.DateTimeFormat(['en'], {timeZone: 'America/Los_Angeles'});

 // Make sure we have pattern we expect (may change in the future).
 assertEquals('M/d/y', dtf.resolved.pattern);

-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 "May".
-assertEquals(undefined, dtf.v8Parse('May 4th 1974'));
+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'));

-// 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'))));
+// Month is numeric, so it fails on "Feb".
+assertEquals(undefined, dtf.v8Parse('Feb 4th 1974'));
=======================================
--- /branches/bleeding_edge/test/intl/date-format/parse-mdyhms.js Thu Oct 10 19:43:05 2013 UTC +++ /branches/bleeding_edge/test/intl/date-format/parse-mdyhms.js Fri Oct 11 17:54:31 2013 UTC
@@ -30,22 +30,28 @@
 var dtf = new Intl.DateTimeFormat(['en'],
                                   {year: 'numeric', month: 'numeric',
                                    day: 'numeric', hour: 'numeric',
-                                   minute: 'numeric', second: 'numeric'});
+                                   minute: 'numeric', second: 'numeric',
+                                   timeZone: 'UTC'});

 // Make sure we have pattern we expect (may change in the future).
 assertEquals('M/d/y h:mm:ss a', dtf.resolved.pattern);

-assertEquals('Sat May 04 1974 12:30:12 GMT-0007 (PDT)',
-             usePDT(String(dtf.v8Parse('5/4/74 12:30:12 pm'))));
+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());

 // AM/PM were not specified.
-assertEquals(undefined, dtf.v8Parse('5/4/74 12:30:12'));
+assertEquals(undefined, dtf.v8Parse('2/4/74 12:30:12'));

 // Time was not specified.
-assertEquals(undefined, dtf.v8Parse('5/4/74'));
+assertEquals(undefined, dtf.v8Parse('2/4/74'));

-// Month is numeric, so it fails on "May".
-assertEquals(undefined, dtf.v8Parse('May 4th 1974'));
+// Month is numeric, so it fails on "Feb".
+assertEquals(undefined, dtf.v8Parse('Feb 4th 1974'));

 // Wrong date delimiter.
-assertEquals(undefined, dtf.v8Parse('5-4-74 12:30:12 am'));
+assertEquals(undefined, dtf.v8Parse('2-4-74 12:30:12 am'));
=======================================
--- /branches/bleeding_edge/test/intl/testcfg.py Thu Oct 10 19:43:05 2013 UTC +++ /branches/bleeding_edge/test/intl/testcfg.py Fri Oct 11 17:54:31 2013 UTC
@@ -57,7 +57,6 @@
     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

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to