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

Side by Side Diff: sdk/lib/core/date_time.dart

Issue 324213003: Change DateTime.parse FormatException messages; update tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: parens Created 6 years, 4 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
« no previous file with comments | « no previous file | tests/corelib/date_time_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * An instant in time, such as July 20, 1969, 8:18pm GMT. 8 * An instant in time, such as July 20, 1969, 8:18pm GMT.
9 * 9 *
10 * Create a DateTime object by using one of the constructors 10 * Create a DateTime object by using one of the constructors
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 * time_opt ::= <empty> | (' ' | 'T') hour minutes_opt 232 * time_opt ::= <empty> | (' ' | 'T') hour minutes_opt
233 * minutes_opt ::= <empty> | ':' digit{2} seconds_opt 233 * minutes_opt ::= <empty> | ':' digit{2} seconds_opt
234 * seconds_opt ::= <empty> | ':' digit{2} millis_opt 234 * seconds_opt ::= <empty> | ':' digit{2} millis_opt
235 * millis_opt ::= <empty> | '.' digit{1,6} 235 * millis_opt ::= <empty> | '.' digit{1,6}
236 * timezone_opt ::= <empty> | space_opt timezone 236 * timezone_opt ::= <empty> | space_opt timezone
237 * space_opt :: ' ' | <empty> 237 * space_opt :: ' ' | <empty>
238 * timezone ::= 'z' | 'Z' | sign digit{2} timezonemins_opt 238 * timezone ::= 'z' | 'Z' | sign digit{2} timezonemins_opt
239 * timezonemins_opt ::= <empty> | colon_opt digit{2} 239 * timezonemins_opt ::= <empty> | colon_opt digit{2}
240 */ 240 */
241 final RegExp re = new RegExp( 241 final RegExp re = new RegExp(
242 r'^([+-]?\d{4,5})-?(\d\d)-?(\d\d)' // The day part. 242 r'^([+-]?\d{4,6})-?(\d\d)-?(\d\d)' // The day part.
243 r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)?' // The time part 243 r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)?' // The time part
244 r'( ?[zZ]| ?([-+])(\d\d)(?::?(\d\d))?)?)?$'); // The timezone part 244 r'( ?[zZ]| ?([-+])(\d\d)(?::?(\d\d))?)?)?$'); // The timezone part
245 245
246 Match match = re.firstMatch(formattedString); 246 Match match = re.firstMatch(formattedString);
247 if (match != null) { 247 if (match != null) {
248 int parseIntOrZero(String matched) { 248 int parseIntOrZero(String matched) {
249 if (matched == null) return 0; 249 if (matched == null) return 0;
250 return int.parse(matched); 250 return int.parse(matched);
251 } 251 }
252 252
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 * In accordance with ISO 8601 622 * In accordance with ISO 8601
623 * a week starts with Monday, which has the value 1. 623 * a week starts with Monday, which has the value 1.
624 * 624 *
625 * DateTime moonLanding = DateTime.parse("1969-07-20 20:18:00"); 625 * DateTime moonLanding = DateTime.parse("1969-07-20 20:18:00");
626 * assert(moonLanding.weekday == 7); 626 * assert(moonLanding.weekday == 7);
627 * assert(moonLanding.weekday == DateTime.SUNDAY); 627 * assert(moonLanding.weekday == DateTime.SUNDAY);
628 * 628 *
629 */ 629 */
630 external int get weekday; 630 external int get weekday;
631 } 631 }
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/date_time_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698