mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
new format: 2017-12-11 10:16 no seconds closes #31
This commit is contained in:
parent
f30ca3179c
commit
39fde9de9e
@ -668,7 +668,13 @@ iterRunes:
|
|||||||
}
|
}
|
||||||
case stateDigitDashWs: // starts digit then dash 02- then whitespace 1 << 2 << 5 + 3
|
case stateDigitDashWs: // starts digit then dash 02- then whitespace 1 << 2 << 5 + 3
|
||||||
// 2013-04-01 22:43:22
|
// 2013-04-01 22:43:22
|
||||||
return parse("2006-01-02 15:04:05", datestr, loc)
|
// 2013-04-01 22:43
|
||||||
|
switch len(datestr) {
|
||||||
|
case len("2013-04-01 22:43"):
|
||||||
|
return parse("2006-01-02 15:04", datestr, loc)
|
||||||
|
default:
|
||||||
|
return parse("2006-01-02 15:04:05", datestr, loc)
|
||||||
|
}
|
||||||
|
|
||||||
case stateDigitDashWsWsOffset:
|
case stateDigitDashWsWsOffset:
|
||||||
// 2006-01-02 15:04:05 -0700
|
// 2006-01-02 15:04:05 -0700
|
||||||
|
@ -365,6 +365,9 @@ func TestParse(t *testing.T) {
|
|||||||
ts = MustParse("2012-08-03 18:31:59.257000000")
|
ts = MustParse("2012-08-03 18:31:59.257000000")
|
||||||
assert.Equal(t, "2012-08-03 18:31:59.257 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
|
assert.Equal(t, "2012-08-03 18:31:59.257 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||||
|
|
||||||
|
ts = MustParse("2013-04-01 22:43")
|
||||||
|
assert.Equal(t, "2013-04-01 22:43:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||||
|
|
||||||
ts = MustParse("2013-04-01 22:43:22")
|
ts = MustParse("2013-04-01 22:43:22")
|
||||||
assert.Equal(t, "2013-04-01 22:43:22 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
|
assert.Equal(t, "2013-04-01 22:43:22 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user