Skip to content

Commit a88ada4

Browse files
authored
Merge ec355f1 into 58ad941
2 parents 58ad941 + ec355f1 commit a88ada4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sdk/lib/core/date_time.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,16 @@ class DateTime implements Comparable<DateTime> {
259259
/// * `"2012-02-27T14+00:00"`
260260
/// * `"-123450101 00:00:00 Z"`: in the year -12345.
261261
/// * `"2002-02-27T14:00:00-0500"`: Same as `"2002-02-27T19:00:00Z"`
262-
// TODO(lrn): restrict incorrect values like 2003-02-29T50:70:80.
263-
// Or not, that may be a breaking change.
262+
///
263+
/// This method accepts out-of-range component values and interprets
264+
/// them as overflows into the next larger component.
265+
/// For example, "2020-01-42" will be parsed as 2020-02-11, because
266+
/// the last valid date in that month is 2020-01-31, so 42 days is
267+
/// interprted as 31 days of that month plus 11 days into the next month.
268+
///
269+
/// To detect and reject invalid component values, use
270+
/// [DateFormat.parseStrict](https://pub.dev/documentation/intl/latest/intl/DateFormat/parseStrict.html)
271+
/// from the [intl](https://pub.dev/packages/intl) package.
264272
static DateTime parse(String formattedString) {
265273
var re = _parseFormat;
266274
Match? match = re.firstMatch(formattedString);

0 commit comments

Comments
 (0)