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

Unified Diff: pkg/intl/lib/date_format_helpers.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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/intl/test/date_time_format_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/date_format_helpers.dart
===================================================================
--- pkg/intl/lib/date_format_helpers.dart (revision 11626)
+++ pkg/intl/lib/date_format_helpers.dart (working copy)
@@ -7,9 +7,11 @@
* up incrementally.
*/
class _DateBuilder {
- int year = 0,
- month = 0,
- day = 0,
+ // Default the date values to the EPOCH so that there's a valid date
+ // in case the format doesn't set them.
+ int year = 1970,
+ month = 1,
+ day = 1,
hour = 0,
minute = 0,
second = 0,
@@ -29,16 +31,9 @@
/**
* Return a date built using our values. If no date portion is set,
- * use today's date, as otherwise the constructor will fail.
+ * use the "Epoch" of January 1, 1970.
*/
Date asDate() {
Anton Muhin 2012/08/30 17:52:11 nit: you may prefer arrow syntax now.
- if (year == 0 || month == 0 || day == 0) {
- var today = new Date.now();
- if (year == 0) year = today.year;
- if (month == 0) month = today.month;
- if (day == 0) day = today.day;
- }
-
// TODO(alanknight): Validate the date, especially for things which
// can crash the VM, e.g. large month values.
return new Date(
« no previous file with comments | « no previous file | pkg/intl/test/date_time_format_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698