mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-13 05:06:36 +08:00
fix 24 hour range on date parse
This commit is contained in:
parent
7b91f1acd1
commit
36dfef3c74
@ -182,7 +182,7 @@ func ParseAny(datestr string) (time.Time, error) {
|
|||||||
//2006-01-02
|
//2006-01-02
|
||||||
//2006-01-02
|
//2006-01-02
|
||||||
if len(datestr) == len("2014-04-26 05:24:37.3186369") {
|
if len(datestr) == len("2014-04-26 05:24:37.3186369") {
|
||||||
if t, err := time.Parse("2006-01-02 03:04:05.0000000", datestr); err == nil {
|
if t, err := time.Parse("2006-01-02 15:04:05.0000000", datestr); err == nil {
|
||||||
return t, nil
|
return t, nil
|
||||||
} else {
|
} else {
|
||||||
u.Error(err)
|
u.Error(err)
|
||||||
|
@ -92,9 +92,9 @@ func TestParse(t *testing.T) {
|
|||||||
assert.T(t, "2009-08-13 05:15:09 +0000 UTC" == fmt.Sprintf("%v", ts2.In(time.UTC)))
|
assert.T(t, "2009-08-13 05:15:09 +0000 UTC" == fmt.Sprintf("%v", ts2.In(time.UTC)))
|
||||||
|
|
||||||
//2014-04-26 05:24:37.3186369
|
//2014-04-26 05:24:37.3186369
|
||||||
ts, err = ParseAny("2014-04-26 05:24:37.3186369")
|
ts, err = ParseAny("2014-04-26 17:24:37.3186369")
|
||||||
assert.T(t, err == nil)
|
assert.T(t, err == nil)
|
||||||
u.Debug(ts.Unix(), ts)
|
u.Debug(ts.Unix(), ts)
|
||||||
assert.T(t, "2014-04-26 05:24:37.3186369 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
assert.T(t, "2014-04-26 17:24:37.3186369 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user