issue-130 fix timezone detection issue after timePeriod

This commit is contained in:
Zifeng Yu 2021-07-24 20:24:59 +08:00
parent 6b43995a97
commit 068594790e
2 changed files with 8 additions and 0 deletions

View File

@ -1503,6 +1503,8 @@ iterRunes:
// 22:18:00.001 +0000 UTC m=+0.000000001
// timePeriodWsAlpha
// 06:20:00.000 UTC
// timeZ
// 15:09:23.099Z
switch r {
case ' ':
p.mslen = i - p.msi
@ -1512,6 +1514,11 @@ iterRunes:
p.mslen = i - p.msi
p.offseti = i
p.stateTime = timePeriodOffset
case 'Z':
p.mslen = i - p.msi
// (Z)ulu time
p.loc = time.UTC
p.stateTime = timeZ
default:
if unicode.IsLetter(r) {
// 06:20:00.000 UTC

View File

@ -389,6 +389,7 @@ var testInputs = []dateTest{
{in: "2009-08-12T22:15Z", out: "2009-08-12 22:15:00 +0000 UTC"},
{in: "2009-08-12T22:15:09Z", out: "2009-08-12 22:15:09 +0000 UTC"},
{in: "2009-08-12T22:15:09.99Z", out: "2009-08-12 22:15:09.99 +0000 UTC"},
{in: "2009-08-12T22:15:09.99Z", out: "2009-08-12 22:15:09.99 +0000 UTC", loc: "Asia/Shanghai"},
{in: "2009-08-12T22:15:09.9999Z", out: "2009-08-12 22:15:09.9999 +0000 UTC"},
{in: "2009-08-12T22:15:09.99999999Z", out: "2009-08-12 22:15:09.99999999 +0000 UTC"},
{in: "2009-08-12T22:15:9.99999999Z", out: "2009-08-12 22:15:09.99999999 +0000 UTC"},