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

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)
@@ -29,14 +29,14 @@
/**
* 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" (January 1, 1970), since the constructor will fail if
Anton Muhin 2012/08/30 17:44:03 nit: I think "since the constructor..." can be omi
Alan Knight 2012/08/30 17:50:40 Done.
+ * given zero values for those fields.
*/
Date asDate() {
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;
+ if (year == 0) year = 1970;
Anton Muhin 2012/08/30 17:44:03 maybe just make those default values for fields?
Alan Knight 2012/08/30 17:50:40 Yes, that's much nicer. Done.
+ if (month == 0) month = 1;
+ if (day == 0) day = 1;
}
// TODO(alanknight): Validate the date, especially for things which
« 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