Skip to content

time: time.Parse day range inconsistency. #18921

@stakhiv

Description

@stakhiv

What version of Go are you using (go version)?

go version go1.7.5 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="darwin"

What did you do?

Parsing of "February 99" returns an error - https://play.golang.org/p/A2vCJo_oS9
But there's no error on parsing "February 00" - https://play.golang.org/p/AbcCMQ4xIo

https://golang.org/pkg/time/#Parse documentation seems to be outdated too.

No checking is done that the day of the month is within the month's valid dates; any one- or two-digit value is accepted. For example February 31 and even February 99 are valid dates, specifying dates in March and May. This behavior is consistent with time.Date.

What did you expect to see?

https://play.golang.org/p/AbcCMQ4xIo should return "day out of range" error for "February 00".

What did you see instead?

No error and previous day instead 0000-01-31 00:00:00 +0000 UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions