Allow strict parsing of Date-only parsing to tolerate 1:00am dates that seem to happen every once in a long while, possibly related to DST transitions.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=194564397
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f733ab..22df2bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 0.15.7
+ * Compensate for rare cases where a parsed Date in date-only format gets a
+ 1:00am time. This is presumably because of DST time-shifts. We may not be
+ able to correct these dates, because midnight may not exist at a transition
+ date, but we can cause the strict parsing to not fail for these dates.
+
## 0.15.6
* More upper case constant removal.
@@ -18,6 +24,10 @@
* Add missing support for specifying decimalDigits in compactSimpleCurrency.
* Fix doc comments for DateFormat (Pull request #156)
* Added a skip argument to not output the message in the extract step.
+ * Compensate for parsing a Date that happens at a DST transition, particularly
+ in Brazil, where the transition happens at midnight. This can result in a
+ time of 11:00pm the previous day, or of 1:00am the next day. Make sure that
+ the the 11:00pm case does not cause us to get the wrong date.
## 0.15.2
* Group the padding digits to the left of the number, if present. e.g. 00,001.
diff --git a/lib/src/intl/date_format_helpers.dart b/lib/src/intl/date_format_helpers.dart
index 12f4460..7781c77 100644
--- a/lib/src/intl/date_format_helpers.dart
+++ b/lib/src/intl/date_format_helpers.dart
@@ -103,7 +103,13 @@
// check the year, which we otherwise can't verify, and the hours,
// which will catch cases like "14:00:00 PM".
var date = asDate();
- _verify(hour24, date.hour, date.hour, "hour", s, date);
+ // On rare occasions, possibly related to DST boundaries, a parsed date will
+ // come out as 1:00am. We compensate for the case of going backwards in
+ // _correctForErrors, but we may not be able to compensate for a midnight
+ // that doesn't exist. So tolerate an hour value of zero or one in these
+ // cases.
+ var minimumDate = _dateOnly && date.hour == 1 ? 0 : date.hour;
+ _verify(hour24, minimumDate, date.hour, "hour", s, date);
if (day > 31) {
// We have an ordinal date, compute the corresponding date for the result
// and compare to that.
diff --git a/pubspec.yaml b/pubspec.yaml
index c065a1a..d1bb179 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: intl
-version: 0.15.6
+version: 0.15.7-dev
author: Dart Team <misc@dartlang.org>
description: Contains code to deal with internationalized/localized messages, date and number formatting and parsing, bi-directional text, and other internationalization issues.
homepage: https://github.com/dart-lang/intl