Skip to content

Commit

Permalink
Add support for float timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
iTanken committed Apr 1, 2024
1 parent ac9ab23 commit f0cdec5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion parseany.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ iterRunes:
// 08.21.71
// 2014.05
p.stateDate = dateDigitDot
if i == 4 {
if i == 10 && len(datestr) <= 14 {
p.stateDate = dateDigit
datestr = datestr[:10] + datestr[11:] + "000"[:14-len(datestr)]
} else if i == 4 {
p.yearlen = i
p.moi = i + 1
p.setYear()
Expand Down
4 changes: 4 additions & 0 deletions parseany_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ var testInputs = []dateTest{
{in: "171113 14:14:20", out: "2017-11-13 14:14:20 +0000 UTC"},

// all digits: unix secs, ms etc
{in: "1332151919.329", out: "2012-03-19 10:11:59.329 +0000 UTC"},
{in: "1332151919.32", out: "2012-03-19 10:11:59.32 +0000 UTC"},
{in: "1332151919.", out: "2012-03-19 10:11:59 +0000 UTC"},
{in: "1332151919.001", out: "2012-03-19 10:11:59.001 +0000 UTC"},
{in: "1332151919", out: "2012-03-19 10:11:59 +0000 UTC"},
{in: "1332151919", out: "2012-03-19 10:11:59 +0000 UTC", loc: "America/Denver"},
{in: "1384216367111", out: "2013-11-12 00:32:47.111 +0000 UTC"},
Expand Down

0 comments on commit f0cdec5

Please sign in to comment.