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 // Test fromString with 6 digits after the decimal point. | 7 // Test fromString with 6 digits after the decimal point. |
8 | 8 |
9 bool get supportsMicroseconds => | 9 bool get supportsMicroseconds => |
10 new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; | 10 new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; |
11 | 11 |
12 | |
13 main() { | 12 main() { |
14 if (supportsMicroseconds) { | 13 if (supportsMicroseconds) { |
15 testMicrosecondPrecision(); | 14 testMicrosecondPrecision(); |
16 } else { | 15 } else { |
17 testMillisecondPrecision(); | 16 testMillisecondPrecision(); |
18 } | 17 } |
19 } | 18 } |
20 | 19 |
21 void testMillisecondPrecision() { | 20 void testMillisecondPrecision() { |
22 // We only support milliseconds. If the user supplies more data (the "51" | 21 // We only support milliseconds. If the user supplies more data (the "51" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 Expect.equals(2012, dt1.year); | 95 Expect.equals(2012, dt1.year); |
97 Expect.equals(3, dt1.month); | 96 Expect.equals(3, dt1.month); |
98 Expect.equals(30, dt1.day); | 97 Expect.equals(30, dt1.day); |
99 Expect.equals(4, dt1.hour); | 98 Expect.equals(4, dt1.hour); |
100 Expect.equals(28, dt1.minute); | 99 Expect.equals(28, dt1.minute); |
101 Expect.equals(13, dt1.second); | 100 Expect.equals(13, dt1.second); |
102 Expect.equals(752, dt1.millisecond); | 101 Expect.equals(752, dt1.millisecond); |
103 Expect.equals(341, dt1.microsecond); | 102 Expect.equals(341, dt1.microsecond); |
104 Expect.equals(true, dt1.isUtc); | 103 Expect.equals(true, dt1.isUtc); |
105 } | 104 } |
OLD | NEW |