OLD | NEW |
---|---|
1 /** | 1 /** |
2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 * for details. All rights reserved. Use of this source code is governed by a | 3 * for details. All rights reserved. Use of this source code is governed by a |
4 * BSD-style license that can be found in the LICENSE file. | 4 * BSD-style license that can be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #library('date_format_test'); | 7 #library('date_time_format_test'); |
8 | 8 |
9 #import('../../../lib/i18n/date_format.dart'); | 9 #import('../../../lib/i18n/date_format.dart');//TODO(efortuna): rename. |
10 #import('../../../lib/unittest/unittest.dart'); | 10 #import('../../../lib/unittest/unittest.dart'); |
11 | 11 |
12 /** | 12 /** |
13 * Tests the DateFormat library in dart. | 13 * Tests the DateFormat library in dart. |
14 */ | 14 */ |
15 | 15 |
16 main() { | 16 main() { |
17 test('Date formatting', () { | 17 test('Date formatting', () { |
18 var date_format = new DateFormat.fullDate(); | 18 var date_format = new DateFormat.fullDate(); |
19 Date date = new Date.now(); | 19 Date date = new Date.now(); |
20 // TODO(efortuna): Change the expectation once we have a functioning date | 20 // TODO(efortuna): Change the expectation once we have a functioning date |
21 // formatting class. | 21 // formatting class. |
22 Expect.stringEquals(date.toString(), date_format.format(date)); | 22 Expect.stringEquals(date.toString(), date_format.format(date)); |
23 | 23 |
24 date_format = new DateFormat("hh:mm:ss"); | 24 date_format = new DateFormat("Hms"); |
25 Expect.stringEquals(date.toString(), date_format.format(date)); | 25 Expect.stringEquals(date.toString(), date_format.format(date)); |
26 | |
27 date_format = new DateFormat(DateFormat.Hms); | |
Alan Knight
2012/06/03 17:19:52
This puts us back to having the extra DateFormat t
| |
28 Expect.stringEquals(date.toString(), date_format.format(date)); | |
29 | |
30 date_format = new DateFormat("Hms"); | |
31 Expect.stringEquals(date.toString(), date_format.format(date)); | |
32 | |
33 var intl = new Intl(); | |
34 intl.date.setFormat = intl.date.y; | |
35 Expect.stringEquals(date.toString(), intl.date.format(date)); | |
36 | |
37 | |
38 intl.date.setFormat = 'y'; | |
39 Expect.stringEquals(date.toString(), intl.date.format(date)); | |
26 }); | 40 }); |
27 | 41 |
28 test('Date parsing', () { | 42 test('Date parsing', () { |
29 var date_format = new DateFormat.fullDate(); | 43 var date_format = new DateFormat.fullDate(); |
30 Date date = new Date.now(); | 44 Date date = new Date.now(); |
31 // TODO(efortuna): Change the expectation once we have a functioning date | 45 // TODO(efortuna): Change the expectation once we have a functioning date |
32 // formatting class. | 46 // formatting class. |
33 Expect.stringEquals(date_format.parse(date.toString()), date.toString()); | 47 Expect.stringEquals(date_format.parse(date.toString()), date.toString()); |
34 }); | 48 }); |
35 } | 49 } |
OLD | NEW |