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 |
172 test('Basic date format parsing', () { | 186 test('Basic date format parsing', () { |
173 var date_format = new DateFormat("d"); | 187 var date_format = new DateFormat("d"); |
174 expect( | 188 expect( |
175 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), | 189 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), |
176 orderedEquals(["hh",":", "mm",":","ss"])); | 190 orderedEquals(["hh",":", "mm",":","ss"])); |
177 expect( | 191 expect( |
178 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), | 192 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), |
179 orderedEquals(["hh",":", "mm",":","ss"])); | 193 orderedEquals(["hh",":", "mm",":","ss"])); |
180 }); | 194 }); |
181 | 195 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 var localPrinted = format.format(local); | 299 var localPrinted = format.format(local); |
286 var parsed = format.parse(localPrinted); | 300 var parsed = format.parse(localPrinted); |
287 var parsedUTC = format.parseUTC(format.format(utc)); | 301 var parsedUTC = format.parseUTC(format.format(utc)); |
288 var parsedOffset = parsedUTC.millisecondsSinceEpoch | 302 var parsedOffset = parsedUTC.millisecondsSinceEpoch |
289 - parsed.millisecondsSinceEpoch; | 303 - parsed.millisecondsSinceEpoch; |
290 expect(parsedOffset, equals(offset)); | 304 expect(parsedOffset, equals(offset)); |
291 expect(utc.hour, equals(parsedUTC.hour)); | 305 expect(utc.hour, equals(parsedUTC.hour)); |
292 expect(local.hour, equals(parsed.hour)); | 306 expect(local.hour, equals(parsed.hour)); |
293 }); | 307 }); |
294 } | 308 } |
OLD | NEW |