OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Dart test program for Date. | 5 // Dart test program for Date. |
6 | 6 |
7 class DateTest { | 7 class DateTest { |
8 // Tests if the time moves eventually forward. | 8 // Tests if the time moves eventually forward. |
9 static void testNow() { | 9 static void testNow() { |
10 var t1 = new Date.now(); | 10 var t1 = new Date.now(); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 var dt3 = dt2.subtract(new Duration(milliseconds: | 316 var dt3 = dt2.subtract(new Duration(milliseconds: |
317 3 * Duration.MILLISECONDS_PER_SECOND + 5)); | 317 3 * Duration.MILLISECONDS_PER_SECOND + 5)); |
318 Expect.equals(true, dt1 == dt3); | 318 Expect.equals(true, dt1 == dt3); |
319 Expect.equals(false, dt1 == dt2); | 319 Expect.equals(false, dt1 == dt2); |
320 } | 320 } |
321 | 321 |
322 static void testDateStrings() { | 322 static void testDateStrings() { |
323 // TODO(floitsch): Clean up the Date API that deals with strings. | 323 // TODO(floitsch): Clean up the Date API that deals with strings. |
324 var dt1 = new Date.fromString("2011-05-11 18:58:35Z"); | 324 var dt1 = new Date.fromString("2011-05-11 18:58:35Z"); |
325 Expect.equals(1305140315000, dt1.value); | 325 Expect.equals(1305140315000, dt1.value); |
| 326 Expect.isTrue(dt1.isUtc()); |
326 var str = dt1.toString(); | 327 var str = dt1.toString(); |
327 var dt2 = new Date.fromString(str); | 328 var dt2 = new Date.fromString(str); |
328 Expect.equals(true, dt1 == dt2); | 329 Expect.equals(true, dt1 == dt2); |
329 var dt3 = dt1.changeTimeZone(const TimeZone.utc()); | 330 var dt3 = dt1.changeTimeZone(const TimeZone.utc()); |
330 str = dt3.toString(); | 331 str = dt3.toString(); |
331 Expect.equals("2011-05-11 18:58:35.000Z", str); | 332 Expect.equals("2011-05-11 18:58:35.000Z", str); |
332 } | 333 } |
333 | 334 |
334 static void testWeekday() { | 335 static void testWeekday() { |
335 // 2011-10-06 is Summertime. | 336 // 2011-10-06 is Summertime. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 testDateStrings(); | 375 testDateStrings(); |
375 testEquivalentYears(); | 376 testEquivalentYears(); |
376 testFarAwayDates(); | 377 testFarAwayDates(); |
377 testWeekday(); | 378 testWeekday(); |
378 } | 379 } |
379 } | 380 } |
380 | 381 |
381 main() { | 382 main() { |
382 DateTest.testMain(); | 383 DateTest.testMain(); |
383 } | 384 } |
OLD | NEW |