wip, failing test for new date format

This commit is contained in:
Aaron Raddon 2014-05-11 08:28:23 -07:00
parent 9e4b7a4b46
commit 6e81432574
2 changed files with 23 additions and 0 deletions

View File

@ -53,6 +53,7 @@ iterRunes:
// 2006-01-02T15:04:05.999999999Z07:00 // 2006-01-02T15:04:05.999999999Z07:00
// 2014-04-26 17:24:37.3186369 // 2014-04-26 17:24:37.3186369
// 2016-03-14 00:00:00.000 // 2016-03-14 00:00:00.000
// 2014-05-11 08:20:13,787
// 2006-01-02 // 2006-01-02
// 2014-04-26 05:24:37 PM // 2014-04-26 05:24:37 PM
switch { switch {
@ -64,6 +65,7 @@ iterRunes:
case 65: // starts digit then dash 02- then whitespace 1 << 2 << 5 + 1 case 65: // starts digit then dash 02- then whitespace 1 << 2 << 5 + 1
// 2014-04-26 17:24:37.3186369 // 2014-04-26 17:24:37.3186369
// 2016-03-14 00:00:00.000 // 2016-03-14 00:00:00.000
// 2014-05-11 08:20:13,787
// 2014-04-26 05:24:37 PM // 2014-04-26 05:24:37 PM
switch r { switch r {
case 'A', 'P': case 'A', 'P':
@ -74,6 +76,14 @@ iterRunes:
u.Error(err) 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 case 67: // starts digit then dash 02- then T 1 << 2 << 5 + 3
// 2006-01-02T15:04:05Z07:00 // 2006-01-02T15:04:05Z07:00

View File

@ -44,6 +44,7 @@ var _ = time.April
2016-03-14 00:00:00.000 2016-03-14 00:00:00.000
2006-01-02 2006-01-02
2014-05-11 08:20:13,787
*/ */
@ -114,6 +115,18 @@ func TestParse(t *testing.T) {
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 00:00:00 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC))) 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) { // func TestParseAMPM(t *testing.T) {