Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parse datetime with zero year #1367

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -26,6 +26,7 @@ Carlos Nieto <jose.carlos at menteslibres.net>
Chris Kirkland <chriskirkland at github.com>
Chris Moos <chris at tech9computers.com>
Craig Wilson <craiggwilson at gmail.com>
Daniel Milde <daniel at milde.cz>
Daniel Montoya <dsmontoyam at gmail.com>
Daniel Nichter <nil at codenode.com>
Daniël van Eeden <git at myname.nl>
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Expand Up @@ -117,7 +117,7 @@ func parseDateTime(b []byte, loc *time.Location) (time.Time, error) {
if err != nil {
return time.Time{}, err
}
if year <= 0 {
if year < 0 {
year = 1
}

Expand Down
4 changes: 4 additions & 0 deletions utils_test.go
Expand Up @@ -351,6 +351,10 @@ func TestParseDateTime(t *testing.T) {
name: "parse datetime nanosec 6-digits",
str: "2020-05-25 23:22:01.159491",
},
{
name: "parse datetime with zero year",
str: "0000-05-25 23:22:01",
},
}

for _, loc := range []*time.Location{
Expand Down