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_time_format_test'); | 7 #library('date_time_format_test'); |
8 | 8 |
9 #import('../intl.dart'); | 9 #import('../intl.dart'); |
10 #import('../date_format.dart'); | 10 #import('../date_format.dart'); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 var format = new DateFormat(skeleton, localeName); | 162 var format = new DateFormat(skeleton, localeName); |
163 var actualResult = format.format(date); | 163 var actualResult = format.format(date); |
164 var parsed = format.parse(actualResult); | 164 var parsed = format.parse(actualResult); |
165 var thenPrintAgain = format.format(parsed); | 165 var thenPrintAgain = format.format(parsed); |
166 expect(thenPrintAgain, equals(actualResult)); | 166 expect(thenPrintAgain, equals(actualResult)); |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 main() { | 171 main() { |
172 test('Multiple patterns', () { | |
173 var date = new Date.now(); | |
174 var multiple1 = new DateFormat.yMd().jms(); | |
175 var multiple2 = new DateFormat("yMd").jms(); | |
176 var separate1 = new DateFormat.yMd(); | |
177 var separate2 = new DateFormat.jms(); | |
178 var separateFormat = "${separate1.format(date)} ${separate2.format(date)}"; | |
179 expect(multiple1.format(date), equals(multiple2.format(date))); | |
180 expect(multiple1.format(date), equals(separateFormat)); | |
181 var customPunctuation = new DateFormat("yMd").addPattern("jms",":::"); | |
182 var custom = "${separate1.format(date)}:::${separate2.format(date)}"; | |
183 expect(customPunctuation.format(date), equals(custom)); | |
184 }); | |
185 | |
186 | |
Emily Fortuna
2012/08/21 22:17:03
extra whitespace here?
Alan Knight
2012/08/21 23:18:05
Done.
| |
172 test('Basic date format parsing', () { | 187 test('Basic date format parsing', () { |
173 var date_format = new DateFormat("d"); | 188 var date_format = new DateFormat("d"); |
174 expect( | 189 expect( |
175 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), | 190 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), |
176 orderedEquals(["hh",":", "mm",":","ss"])); | 191 orderedEquals(["hh",":", "mm",":","ss"])); |
177 expect( | 192 expect( |
178 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), | 193 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), |
179 orderedEquals(["hh",":", "mm",":","ss"])); | 194 orderedEquals(["hh",":", "mm",":","ss"])); |
180 }); | 195 }); |
181 | 196 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 var localPrinted = format.format(local); | 300 var localPrinted = format.format(local); |
286 var parsed = format.parse(localPrinted); | 301 var parsed = format.parse(localPrinted); |
287 var parsedUTC = format.parseUTC(format.format(utc)); | 302 var parsedUTC = format.parseUTC(format.format(utc)); |
288 var parsedOffset = parsedUTC.millisecondsSinceEpoch | 303 var parsedOffset = parsedUTC.millisecondsSinceEpoch |
289 - parsed.millisecondsSinceEpoch; | 304 - parsed.millisecondsSinceEpoch; |
290 expect(parsedOffset, equals(offset)); | 305 expect(parsedOffset, equals(offset)); |
291 expect(utc.hour, equals(parsedUTC.hour)); | 306 expect(utc.hour, equals(parsedUTC.hour)); |
292 expect(local.hour, equals(parsed.hour)); | 307 expect(local.hour, equals(parsed.hour)); |
293 }); | 308 }); |
294 } | 309 } |
OLD | NEW |