mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
Fix time-zone for certain formats closes #68
This commit is contained in:
parent
42dbd9f872
commit
cfd92a431d
@ -1072,6 +1072,12 @@ iterRunes:
|
|||||||
p.offseti = i
|
p.offseti = i
|
||||||
case ' ':
|
case ' ':
|
||||||
// 17:57:51 MST 2009
|
// 17:57:51 MST 2009
|
||||||
|
p.tzlen = i - p.tzi
|
||||||
|
if p.tzlen == 4 {
|
||||||
|
p.set(p.tzi, " MST")
|
||||||
|
} else if p.tzlen == 3 {
|
||||||
|
p.set(p.tzi, "MST")
|
||||||
|
}
|
||||||
p.stateTime = timeWsAlphaWs
|
p.stateTime = timeWsAlphaWs
|
||||||
p.yeari = i + 1
|
p.yeari = i + 1
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
func TestOne(t *testing.T) {
|
func TestOne(t *testing.T) {
|
||||||
time.Local = time.UTC
|
time.Local = time.UTC
|
||||||
var ts time.Time
|
var ts time.Time
|
||||||
ts = MustParse("sept. 28, 2017")
|
ts = MustParse("Thu May 08 17:57:51 CEST 2009")
|
||||||
assert.Equal(t, "2017-09-28 00:00:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
|
assert.Equal(t, "2009-05-08 17:57:51 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type dateTest struct {
|
type dateTest struct {
|
||||||
@ -47,6 +47,7 @@ var testInputs = []dateTest{
|
|||||||
{in: "Thu May 8 17:57:51 MST 2009", out: "2009-05-08 17:57:51 +0000 UTC"},
|
{in: "Thu May 8 17:57:51 MST 2009", out: "2009-05-08 17:57:51 +0000 UTC"},
|
||||||
{in: "Thu May 8 17:57:51 PST 2009", out: "2009-05-08 17:57:51 +0000 UTC"},
|
{in: "Thu May 8 17:57:51 PST 2009", out: "2009-05-08 17:57:51 +0000 UTC"},
|
||||||
{in: "Thu May 08 17:57:51 PST 2009", out: "2009-05-08 17:57:51 +0000 UTC"},
|
{in: "Thu May 08 17:57:51 PST 2009", out: "2009-05-08 17:57:51 +0000 UTC"},
|
||||||
|
{in: "Thu May 08 17:57:51 CEST 2009", out: "2009-05-08 17:57:51 +0000 UTC"},
|
||||||
{in: "Thu May 08 05:05:07 PST 2009", out: "2009-05-08 05:05:07 +0000 UTC"},
|
{in: "Thu May 08 05:05:07 PST 2009", out: "2009-05-08 05:05:07 +0000 UTC"},
|
||||||
{in: "Thu May 08 5:5:7 PST 2009", out: "2009-05-08 05:05:07 +0000 UTC"},
|
{in: "Thu May 08 5:5:7 PST 2009", out: "2009-05-08 05:05:07 +0000 UTC"},
|
||||||
// ??
|
// ??
|
||||||
|
Loading…
Reference in New Issue
Block a user