Skip to content

fix: parse Unix second timestamps from numeric strings in ToTimeE - #365

Closed
00200200 wants to merge 1 commit into
spf13:masterfrom
00200200:fix-totime-unix-numeric-string
Closed

00200200 wants to merge 1 commit into
spf13:masterfrom
00200200:fix-totime-unix-numeric-string

Conversation

@00200200

Copy link
Copy Markdown

Summary

Fixes #102.

ToTimeE(1600285405) already succeeds because integer inputs are treated as Unix seconds, but ToTimeE("1600285405") failed with unable to parse date. After named/date formats miss, accept pure numeric strings with 10+ digits (including a leading +/-) as Unix seconds so the string path matches the integer path. Short values like "2006" still fail date parsing and are not treated as timestamps.

Test plan

  • go test ./...
  • Extended TestTime with string Unix cases from [BUG] Unixtimestemp in string #102 ("1600285405", "1234567890") plus a pre-epoch signed string
  • Confirmed "2006" and other short numeric strings still error

Integer inputs already become time.Unix values, but the same digits as a
string failed date parsing. Accept 10+ digit numeric strings (and signed
equivalents) as Unix seconds after named formats miss, fixing #102.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@00200200

00200200 commented Oct 5, 2026

Copy link
Copy Markdown
Author

Closing this PR as I will not be signing the CLA. Thank you!

@00200200 00200200 closed this Oct 5, 2026
@00200200
00200200 deleted the fix-totime-unix-numeric-string branch October 5, 2026 12:15
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.

[BUG] Unixtimestemp in string

2 participants