diff --git a/src/time/format.go b/src/time/format.go index 3608b04e445..3fbfa734d05 100644 --- a/src/time/format.go +++ b/src/time/format.go @@ -1012,7 +1012,7 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error) } // Validate the day of the month. - if day > daysIn(Month(month), year) { + if day < 1 || day > daysIn(Month(month), year) { return Time{}, &ParseError{alayout, avalue, "", value, ": day out of range"} } diff --git a/src/time/format_test.go b/src/time/format_test.go index 640e8180e39..aa4434a09c3 100644 --- a/src/time/format_test.go +++ b/src/time/format_test.go @@ -224,6 +224,7 @@ var dayOutOfRangeTests = []struct { {"Thu Nov 31 21:00:57 2010", false}, {"Thu Dec 31 21:00:57 2010", true}, {"Thu Dec 32 21:00:57 2010", false}, + {"Thu Dec 00 21:00:57 2010", false}, } func TestParseDayOutOfRange(t *testing.T) {