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

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

Issue 389603002: Add extra information to FormatException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 5 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 // 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 int sign = (match[9] == '-') ? -1 : 1; 275 int sign = (match[9] == '-') ? -1 : 1;
276 int hourDifference = int.parse(match[10]); 276 int hourDifference = int.parse(match[10]);
277 int minuteDifference = parseIntOrZero(match[11]); 277 int minuteDifference = parseIntOrZero(match[11]);
278 minuteDifference += 60 * hourDifference; 278 minuteDifference += 60 * hourDifference;
279 minute -= sign * minuteDifference; 279 minute -= sign * minuteDifference;
280 } 280 }
281 } 281 }
282 int millisecondsSinceEpoch = _brokenDownDateToMillisecondsSinceEpoch( 282 int millisecondsSinceEpoch = _brokenDownDateToMillisecondsSinceEpoch(
283 years, month, day, hour, minute, second, millisecond, isUtc); 283 years, month, day, hour, minute, second, millisecond, isUtc);
284 if (millisecondsSinceEpoch == null) { 284 if (millisecondsSinceEpoch == null) {
285 throw new FormatException(formattedString); 285 throw new FormatException("Time out of range", formattedString);
286 } 286 }
287 if (addOneMillisecond) millisecondsSinceEpoch++; 287 if (addOneMillisecond) millisecondsSinceEpoch++;
288 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, 288 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch,
289 isUtc: isUtc); 289 isUtc: isUtc);
290 } else { 290 } else {
291 throw new FormatException(formattedString); 291 throw new FormatException("Invalid date format", formattedString);
292 } 292 }
293 } 293 }
294 294
295 static const int _MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000; 295 static const int _MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000;
296 296
297 /** 297 /**
298 * Constructs a new [DateTime] instance 298 * Constructs a new [DateTime] instance
299 * with the given [millisecondsSinceEpoch]. 299 * with the given [millisecondsSinceEpoch].
300 * 300 *
301 * If [isUtc] is false then the date is in the local time zone. 301 * If [isUtc] is false then the date is in the local time zone.
(...skipping 320 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

Powered by Google App Engine
This is Rietveld 408576698