OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Dart test program for DateTime. | 7 // Dart test program for DateTime. |
8 | 8 |
9 bool get supportsMicroseconds => | 9 bool get supportsMicroseconds => |
10 new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; | 10 new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 d = new DateTime(2011, 9, 30, 23, 45, 37, 0); | 1227 d = new DateTime(2011, 9, 30, 23, 45, 37, 0); |
1228 Expect.equals(DateTime.FRIDAY, d.weekday); | 1228 Expect.equals(DateTime.FRIDAY, d.weekday); |
1229 } | 1229 } |
1230 | 1230 |
1231 void testToStrings() { | 1231 void testToStrings() { |
1232 void test(date, time) { | 1232 void test(date, time) { |
1233 { // UTC time. | 1233 { // UTC time. |
1234 String source1 = "$date ${time}Z"; | 1234 String source1 = "$date ${time}Z"; |
1235 String source2 = "${date}T${time}Z"; | 1235 String source2 = "${date}T${time}Z"; |
1236 var utcTime1 = DateTime.parse(source1); | 1236 var utcTime1 = DateTime.parse(source1); |
1237 var utcTime2 = DateTime.parse(source1); | 1237 var utcTime2 = DateTime.parse(source2); |
1238 Expect.isTrue(utcTime1.isUtc); | 1238 Expect.isTrue(utcTime1.isUtc); |
1239 Expect.equals(utcTime1, utcTime2); | 1239 Expect.equals(utcTime1, utcTime2); |
1240 Expect.equals(source1, utcTime1.toString()); | 1240 Expect.equals(source1, utcTime1.toString()); |
1241 Expect.equals(source2, utcTime1.toIso8601String()); | 1241 Expect.equals(source2, utcTime1.toIso8601String()); |
1242 } | 1242 } |
1243 { // Local time | 1243 { // Local time |
1244 String source1 = "$date $time"; | 1244 String source1 = "$date $time"; |
1245 String source2 = "${date}T$time"; | 1245 String source2 = "${date}T$time"; |
1246 var utcTime1 = DateTime.parse(source1); | 1246 var utcTime1 = DateTime.parse(source1); |
1247 var utcTime2 = DateTime.parse(source1); | 1247 var utcTime2 = DateTime.parse(source2); |
1248 Expect.isFalse(utcTime1.isUtc); | 1248 Expect.isFalse(utcTime1.isUtc); |
1249 Expect.equals(utcTime1, utcTime2); | 1249 Expect.equals(utcTime1, utcTime2); |
1250 Expect.equals(source1, utcTime1.toString()); | 1250 Expect.equals(source1, utcTime1.toString()); |
1251 Expect.equals(source2, utcTime1.toIso8601String()); | 1251 Expect.equals(source2, utcTime1.toIso8601String()); |
1252 } | 1252 } |
1253 } | 1253 } |
1254 test("2000-01-01", "12:00:00.000"); | 1254 test("2000-01-01", "12:00:00.000"); |
1255 test("-2000-01-01", "12:00:00.000"); | 1255 test("-2000-01-01", "12:00:00.000"); |
1256 test("1970-01-01", "00:00:00.000"); | 1256 test("1970-01-01", "00:00:00.000"); |
1257 test("1969-12-31", "23:59:59.999"); | 1257 test("1969-12-31", "23:59:59.999"); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 testSubAdd(); | 1335 testSubAdd(); |
1336 testUnderflowAndOverflow(); | 1336 testUnderflowAndOverflow(); |
1337 testDateStrings(); | 1337 testDateStrings(); |
1338 testEquivalentYears(); | 1338 testEquivalentYears(); |
1339 testExtremes(); | 1339 testExtremes(); |
1340 testFarAwayDates(); | 1340 testFarAwayDates(); |
1341 testWeekday(); | 1341 testWeekday(); |
1342 testToStrings(); | 1342 testToStrings(); |
1343 testIsoString(); | 1343 testIsoString(); |
1344 } | 1344 } |
OLD | NEW |