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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 DateFormat.ABBR_WEEKDAY, | 151 DateFormat.ABBR_WEEKDAY, |
152 DateFormat.WEEKDAY, | 152 DateFormat.WEEKDAY, |
153 DateFormat.QUARTER, | 153 DateFormat.QUARTER, |
154 DateFormat.ABBR_QUARTER, | 154 DateFormat.ABBR_QUARTER, |
155 DateFormat.YEAR, | 155 DateFormat.YEAR, |
156 DateFormat.YEAR_NUM_MONTH, | 156 DateFormat.YEAR_NUM_MONTH, |
157 DateFormat.YEAR_ABBR_MONTH, | 157 DateFormat.YEAR_ABBR_MONTH, |
158 DateFormat.YEAR_MONTH]; | 158 DateFormat.YEAR_MONTH]; |
159 for(int i = 0; i < formatsToTest.length; i++) { | 159 for(int i = 0; i < formatsToTest.length; i++) { |
160 var skeleton = formatsToTest[i]; | 160 var skeleton = formatsToTest[i]; |
161 var format = new DateFormat(skeleton, localeName); | 161 if (!badSkeletons.some((x) => x == skeleton)) { |
162 var badPatterns = badSkeletons.map( | 162 var format = new DateFormat(skeleton, localeName); |
163 (x) => new DateFormat(x, format.locale).pattern); | |
164 | |
165 if (!badPatterns.some((x) => x == format.pattern)) { | |
166 var actualResult = format.format(date); | 163 var actualResult = format.format(date); |
167 var parsed = format.parse(actualResult); | 164 var parsed = format.parse(actualResult); |
168 var thenPrintAgain = format.format(parsed); | 165 var thenPrintAgain = format.format(parsed); |
169 expect(thenPrintAgain, equals(actualResult)); | 166 expect(thenPrintAgain, equals(actualResult)); |
170 } | 167 } |
171 } | 168 } |
172 } | 169 } |
173 | 170 |
174 main() { | 171 main() { |
175 test('Basic date format parsing', () { | 172 test('Basic date format parsing', () { |
176 var date_format = new DateFormat(); | 173 var date_format = new DateFormat("d"); |
177 expect( | 174 expect( |
178 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), | 175 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), |
179 orderedEquals(["hh",":", "mm",":","ss"])); | 176 orderedEquals(["hh",":", "mm",":","ss"])); |
180 expect( | 177 expect( |
181 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), | 178 date_format.parsePattern("hh:mm:ss").map((x) => x.pattern), |
182 orderedEquals(["hh",":", "mm",":","ss"])); | 179 orderedEquals(["hh",":", "mm",":","ss"])); |
183 }); | 180 }); |
184 | 181 |
185 test('Test ALL the supported formats on representative locales', () { | 182 test('Test ALL the supported formats on representative locales', () { |
186 var aDate = new Date(2012, 1, 27, 20, 58, 59, 0, false); | 183 var aDate = new Date(2012, 1, 27, 20, 58, 59, 0, false); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 var localPrinted = format.format(local); | 285 var localPrinted = format.format(local); |
289 var parsed = format.parse(localPrinted); | 286 var parsed = format.parse(localPrinted); |
290 var parsedUTC = format.parseUTC(format.format(utc)); | 287 var parsedUTC = format.parseUTC(format.format(utc)); |
291 var parsedOffset = parsedUTC.millisecondsSinceEpoch | 288 var parsedOffset = parsedUTC.millisecondsSinceEpoch |
292 - parsed.millisecondsSinceEpoch; | 289 - parsed.millisecondsSinceEpoch; |
293 expect(parsedOffset, equals(offset)); | 290 expect(parsedOffset, equals(offset)); |
294 expect(utc.hour, equals(parsedUTC.hour)); | 291 expect(utc.hour, equals(parsedUTC.hour)); |
295 expect(local.hour, equals(parsed.hour)); | 292 expect(local.hour, equals(parsed.hour)); |
296 }); | 293 }); |
297 } | 294 } |
OLD | NEW |