Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: pkg/intl/test/date_time_format_test.dart

Issue 10916015: Parsing dates with format that's just month or day will fail on certain days (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // the skeleton WEEKDAY can't be reconstructed at all, and YEAR_MONTH 148 // the skeleton WEEKDAY can't be reconstructed at all, and YEAR_MONTH
149 // formats don't give us enough information to construct a valid date. 149 // formats don't give us enough information to construct a valid date.
150 var badSkeletons = [ 150 var badSkeletons = [
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 DateFormat.MONTH_WEEKDAY_DAY,
160 DateFormat.NUM_MONTH_WEEKDAY_DAY,
161 DateFormat.ABBR_MONTH_WEEKDAY_DAY];
159 for(int i = 0; i < formatsToTest.length; i++) { 162 for(int i = 0; i < formatsToTest.length; i++) {
160 var skeleton = formatsToTest[i]; 163 var skeleton = formatsToTest[i];
161 if (!badSkeletons.some((x) => x == skeleton)) { 164 if (!badSkeletons.some((x) => x == skeleton)) {
162 var format = new DateFormat(skeleton, localeName); 165 var format = new DateFormat(skeleton, localeName);
163 var actualResult = format.format(date); 166 var actualResult = format.format(date);
164 var parsed = format.parse(actualResult); 167 var parsed = format.parse(actualResult);
165 var thenPrintAgain = format.format(parsed); 168 var thenPrintAgain = format.format(parsed);
166 expect(thenPrintAgain, equals(actualResult)); 169 expect(thenPrintAgain, equals(actualResult));
167 } 170 }
168 } 171 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 var localPrinted = format.format(local); 302 var localPrinted = format.format(local);
300 var parsed = format.parse(localPrinted); 303 var parsed = format.parse(localPrinted);
301 var parsedUTC = format.parseUTC(format.format(utc)); 304 var parsedUTC = format.parseUTC(format.format(utc));
302 var parsedOffset = parsedUTC.millisecondsSinceEpoch 305 var parsedOffset = parsedUTC.millisecondsSinceEpoch
303 - parsed.millisecondsSinceEpoch; 306 - parsed.millisecondsSinceEpoch;
304 expect(parsedOffset, equals(offset)); 307 expect(parsedOffset, equals(offset));
305 expect(utc.hour, equals(parsedUTC.hour)); 308 expect(utc.hour, equals(parsedUTC.hour));
306 expect(local.hour, equals(parsed.hour)); 309 expect(local.hour, equals(parsed.hour));
307 }); 310 });
308 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698