Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1279)

Side by Side Diff: test/mjsunit/date.js

Issue 8423004: Adapt date test to be timezone independant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 assertTrue(isNaN(d.getTime())); 183 assertTrue(isNaN(d.getTime()));
184 d = new Date(1969, 12, 1, -99999999999); 184 d = new Date(1969, 12, 1, -99999999999);
185 assertTrue(isNaN(d.getTime())); 185 assertTrue(isNaN(d.getTime()));
186 d = new Date(1969, 12, 1, Infinity); 186 d = new Date(1969, 12, 1, Infinity);
187 assertTrue(isNaN(d.getTime())); 187 assertTrue(isNaN(d.getTime()));
188 d = new Date(1969, 12, 1, -Infinity); 188 d = new Date(1969, 12, 1, -Infinity);
189 assertTrue(isNaN(d.getTime())); 189 assertTrue(isNaN(d.getTime()));
190 190
191 191
192 // Test creation with obscure date values. 192 // Test creation with obscure date values.
193 var timezoneOffset = new Date().getTimezoneOffset(); 193 assertEquals(8640000000000000, Date.UTC(1970, 0, 1 + 100000001, -24));
194 d = new Date(1970, 0, 1 + 100000001, -24, -timezoneOffset); 194 assertEquals(-8640000000000000, Date.UTC(1970, 0, 1 - 100000001, 24));
195 assertFalse(isNaN(d.getTime()));
196 assertEquals(8640000000000000, d.getTime())
197 d = new Date(1970, 0, 1 - 100000001, 24, -timezoneOffset);
198 assertFalse(isNaN(d.getTime()));
199 assertEquals(-8640000000000000, d.getTime())
200 195
201 196
202 // Parsing ES5 ISO-8601 dates. 197 // Parsing ES5 ISO-8601 dates.
203 // When TZ is omitted, it defaults to 'Z' meaning UTC. 198 // When TZ is omitted, it defaults to 'Z' meaning UTC.
204 199
205 // Check epoch. 200 // Check epoch.
206 assertEquals(0, Date.parse("1970-01-01T00:00:00.000+00:00")); 201 assertEquals(0, Date.parse("1970-01-01T00:00:00.000+00:00"));
207 assertEquals(0, Date.parse("1970-01-01T00:00:00.000-00:00")); 202 assertEquals(0, Date.parse("1970-01-01T00:00:00.000-00:00"));
208 assertEquals(0, Date.parse("1970-01-01T00:00:00.000Z")); 203 assertEquals(0, Date.parse("1970-01-01T00:00:00.000Z"));
209 assertEquals(0, Date.parse("1970-01-01T00:00:00.000")); 204 assertEquals(0, Date.parse("1970-01-01T00:00:00.000"));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 var hh = (i < 10) ? "0" + i : "" + i; 306 var hh = (i < 10) ? "0" + i : "" + i;
312 for (var j = 0; j < 60; j += 15) { 307 for (var j = 0; j < 60; j += 15) {
313 var mm = (j < 10) ? "0" + j : "" + j; 308 var mm = (j < 10) ? "0" + j : "" + j;
314 var ms = (i * 60 + j) * 60000; 309 var ms = (i * 60 + j) * 60000;
315 var string = "1972-03-28T23:50:03.500-" + hh + ":" + mm; 310 var string = "1972-03-28T23:50:03.500-" + hh + ":" + mm;
316 assertEquals(70674603500 + ms, Date.parse(string), string); 311 assertEquals(70674603500 + ms, Date.parse(string), string);
317 string = "1972-03-28T23:50:03.500+" + hh + ":" + mm; 312 string = "1972-03-28T23:50:03.500+" + hh + ":" + mm;
318 assertEquals(70674603500 - ms, Date.parse(string), string); 313 assertEquals(70674603500 - ms, Date.parse(string), string);
319 } 314 }
320 } 315 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698