| 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 // Test fromString with 6 digits after the decimal point. | 5 // Test fromString with 6 digits after the decimal point. |
| 6 | 6 |
| 7 main() { | 7 main() { |
| 8 // We only support milliseconds. If the user supplies more data (the "51" | 8 // We only support milliseconds. If the user supplies more data (the "51" |
| 9 // here), we round. | 9 // here), we round. |
| 10 // If (eventually) we support more than just milliseconds this test could | 10 // If (eventually) we support more than just milliseconds this test could |
| 11 // fail. Please update the test in this case. | 11 // fail. Please update the test in this case. |
| 12 Date dt1 = new Date.fromString("1999-01-02 23:59:59.999519"); | 12 DateTime dt1 = new DateTime.fromString("1999-01-02 23:59:59.999519"); |
| 13 Expect.equals(1999, dt1.year); | 13 Expect.equals(1999, dt1.year); |
| 14 Expect.equals(1, dt1.month); | 14 Expect.equals(1, dt1.month); |
| 15 Expect.equals(3, dt1.day); | 15 Expect.equals(3, dt1.day); |
| 16 Expect.equals(0, dt1.hour); | 16 Expect.equals(0, dt1.hour); |
| 17 Expect.equals(0, dt1.minute); | 17 Expect.equals(0, dt1.minute); |
| 18 Expect.equals(0, dt1.second); | 18 Expect.equals(0, dt1.second); |
| 19 Expect.equals(0, dt1.millisecond); | 19 Expect.equals(0, dt1.millisecond); |
| 20 Expect.equals(false, dt1.isUtc); | 20 Expect.equals(false, dt1.isUtc); |
| 21 dt1 = new Date.fromString("1999-01-02 23:58:59.999519Z"); | 21 dt1 = new DateTime.fromString("1999-01-02 23:58:59.999519Z"); |
| 22 Expect.equals(1999, dt1.year); | 22 Expect.equals(1999, dt1.year); |
| 23 Expect.equals(1, dt1.month); | 23 Expect.equals(1, dt1.month); |
| 24 Expect.equals(2, dt1.day); | 24 Expect.equals(2, dt1.day); |
| 25 Expect.equals(23, dt1.hour); | 25 Expect.equals(23, dt1.hour); |
| 26 Expect.equals(59, dt1.minute); | 26 Expect.equals(59, dt1.minute); |
| 27 Expect.equals(0, dt1.second); | 27 Expect.equals(0, dt1.second); |
| 28 Expect.equals(0, dt1.millisecond); | 28 Expect.equals(0, dt1.millisecond); |
| 29 Expect.equals(true, dt1.isUtc); | 29 Expect.equals(true, dt1.isUtc); |
| 30 dt1 = new Date.fromString("0009-09-09 09:09:09.009411Z"); | 30 dt1 = new DateTime.fromString("0009-09-09 09:09:09.009411Z"); |
| 31 Expect.equals(9, dt1.year); | 31 Expect.equals(9, dt1.year); |
| 32 Expect.equals(9, dt1.month); | 32 Expect.equals(9, dt1.month); |
| 33 Expect.equals(9, dt1.day); | 33 Expect.equals(9, dt1.day); |
| 34 Expect.equals(9, dt1.hour); | 34 Expect.equals(9, dt1.hour); |
| 35 Expect.equals(9, dt1.minute); | 35 Expect.equals(9, dt1.minute); |
| 36 Expect.equals(9, dt1.second); | 36 Expect.equals(9, dt1.second); |
| 37 Expect.equals(9, dt1.millisecond); | 37 Expect.equals(9, dt1.millisecond); |
| 38 Expect.equals(true, dt1.isUtc); | 38 Expect.equals(true, dt1.isUtc); |
| 39 String svnDate = "2012-03-30T04:28:13.752341Z"; | 39 String svnDate = "2012-03-30T04:28:13.752341Z"; |
| 40 dt1 = new Date.fromString(svnDate); | 40 dt1 = new DateTime.fromString(svnDate); |
| 41 Expect.equals(2012, dt1.year); | 41 Expect.equals(2012, dt1.year); |
| 42 Expect.equals(3, dt1.month); | 42 Expect.equals(3, dt1.month); |
| 43 Expect.equals(30, dt1.day); | 43 Expect.equals(30, dt1.day); |
| 44 Expect.equals(4, dt1.hour); | 44 Expect.equals(4, dt1.hour); |
| 45 Expect.equals(28, dt1.minute); | 45 Expect.equals(28, dt1.minute); |
| 46 Expect.equals(13, dt1.second); | 46 Expect.equals(13, dt1.second); |
| 47 Expect.equals(752, dt1.millisecond); | 47 Expect.equals(752, dt1.millisecond); |
| 48 Expect.equals(true, dt1.isUtc); | 48 Expect.equals(true, dt1.isUtc); |
| 49 | 49 |
| 50 } | 50 } |
| OLD | NEW |