Add support for float timestamp

This commit is contained in:
masihbr 2022-02-01 18:34:30 +03:30
parent 6b43995a97
commit c16f802ac4
3 changed files with 8 additions and 2 deletions

1
go.sum
View File

@ -8,7 +8,6 @@ github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4 h1:8qmTC5ByIXO3GP/IzBkxcZ/99VITvnIETDhdFz/om7A= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4 h1:8qmTC5ByIXO3GP/IzBkxcZ/99VITvnIETDhdFz/om7A=
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=

View File

@ -368,7 +368,10 @@ iterRunes:
// 08.21.71 // 08.21.71
// 2014.05 // 2014.05
p.stateDate = dateDigitDot 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.yearlen = i
p.moi = i + 1 p.moi = i + 1
p.setYear() p.setYear()

View File

@ -412,6 +412,10 @@ var testInputs = []dateTest{
{in: "171113 14:14:20", out: "2017-11-13 14:14:20 +0000 UTC"}, {in: "171113 14:14:20", out: "2017-11-13 14:14:20 +0000 UTC"},
// all digits: unix secs, ms etc // 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"},
{in: "1332151919", out: "2012-03-19 10:11:59 +0000 UTC", loc: "America/Denver"}, {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"}, {in: "1384216367111", out: "2013-11-12 00:32:47.111 +0000 UTC"},