mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
wip, failing test for new date format
This commit is contained in:
parent
9e4b7a4b46
commit
6e81432574
10
parseany.go
10
parseany.go
@ -53,6 +53,7 @@ iterRunes:
|
||||
// 2006-01-02T15:04:05.999999999Z07:00
|
||||
// 2014-04-26 17:24:37.3186369
|
||||
// 2016-03-14 00:00:00.000
|
||||
// 2014-05-11 08:20:13,787
|
||||
// 2006-01-02
|
||||
// 2014-04-26 05:24:37 PM
|
||||
switch {
|
||||
@ -64,6 +65,7 @@ iterRunes:
|
||||
case 65: // starts digit then dash 02- then whitespace 1 << 2 << 5 + 1
|
||||
// 2014-04-26 17:24:37.3186369
|
||||
// 2016-03-14 00:00:00.000
|
||||
// 2014-05-11 08:20:13,787
|
||||
// 2014-04-26 05:24:37 PM
|
||||
switch r {
|
||||
case 'A', 'P':
|
||||
@ -74,6 +76,14 @@ iterRunes:
|
||||
u.Error(err)
|
||||
}
|
||||
}
|
||||
case ',':
|
||||
if len(datestr) == len("2014-05-11 08:20:13,787") {
|
||||
if t, err := time.Parse("2006-01-02 03:04:05,999", datestr); err == nil {
|
||||
return t, nil
|
||||
} else {
|
||||
u.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
case 67: // starts digit then dash 02- then T 1 << 2 << 5 + 3
|
||||
// 2006-01-02T15:04:05Z07:00
|
||||
|
@ -44,6 +44,7 @@ var _ = time.April
|
||||
|
||||
2016-03-14 00:00:00.000
|
||||
2006-01-02
|
||||
2014-05-11 08:20:13,787
|
||||
|
||||
*/
|
||||
|
||||
@ -114,6 +115,18 @@ func TestParse(t *testing.T) {
|
||||
assert.T(t, err == nil)
|
||||
//u.Debug(ts.Unix(), ts)
|
||||
assert.T(t, "2014-04-26 00:00:00 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||
|
||||
ts, err = ParseAny("2014-05-11 08:20:13,787")
|
||||
assert.T(t, err == nil)
|
||||
//u.Debug(ts.Unix(), ts)
|
||||
assert.T(t, "2014-04-26 00:00:00 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||
}
|
||||
|
||||
func TestME(t *testing.T) {
|
||||
ts, err := ParseAny("2014-05-11 08:20:13,787")
|
||||
assert.T(t, err == nil)
|
||||
u.Debug(ts.Unix(), ts)
|
||||
assert.T(t, "2014-04-26 17:24:37 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||
}
|
||||
|
||||
// func TestParseAMPM(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user