Skip to content

Fix strptime rejecting the zero time instant - #333

Merged
itchyny merged 1 commit into
itchyny:mainfrom
sinzbtw:sinzbtw/fix-strptime-zero-time
Nov 1, 2026
Merged

itchyny merged 1 commit into
itchyny:mainfrom
sinzbtw:sinzbtw/fix-strptime-zero-time

Conversation

@sinzbtw

@sinzbtw sinzbtw commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

"0001-01-01T00:00:00Z" | strptime("%Y-%m-%dT%H:%M:%S%z") currently fails even though the underlying parser successfully parses the timestamp. It equals Go's zero time.Time, which is also a valid instant.

Remove the zero-time rejection and rely on the parser's error result. The CLI regression covers UTC midnight, the same instant with a +0100 offset, and a neighboring second.

go test ./... -count=1 passes on windows/amd64 and windows/386 with Go 1.27.3. go vet ./..., gofmt and the project's staticcheck invocation pass.

@itchyny
itchyny merged commit e169ed9 into itchyny:main Nov 1, 2026
11 checks passed
W-Floyd added a commit to modopayments/gojq that referenced this pull request Nov 4, 2026
Replaces the builtin.jq fraction split. time.Parse takes any fraction (. or ,) and Z, +hh:mm or +hhmm offsets, and the zero-time rejection now lives here rather than in strptime (upstream itchyny#333 drops it there).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
W-Floyd added a commit to modopayments/gojq that referenced this pull request Nov 4, 2026
Parse with time.Parse instead of strptime: RFC 3339 allows a fraction (. or ,), which strptime's %f caps at 6 digits. +hhmm offsets still parse. The zero-time rejection moves here from strptime, which upstream itchyny#333 drops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants