More date formats closes #46

This commit is contained in:
Aaron Raddon
2018-03-10 13:43:16 -08:00
parent 62e766bf9e
commit a653ec7165
2 changed files with 54 additions and 9 deletions

View File

@@ -119,6 +119,18 @@ func TestOne(t *testing.T) {
ts = MustParse("2014-05-11 08:20:13,787")
assert.Equal(t, "2014-05-11 08:20:13.787 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
}
type dateTest struct {
in, out string
}
var testInputs = []dateTest{
{in: "oct 7, 1970", out: "1970-10-07 00:00:00 +0000 UTC"},
{in: "oct 7, '70", out: "1970-10-07 00:00:00 +0000 UTC"},
{in: "7 oct 70", out: "1970-10-07 00:00:00 +0000 UTC"},
{in: "7 oct 1970", out: "1970-10-07 00:00:00 +0000 UTC"},
}
func TestParse(t *testing.T) {
/*
@@ -138,6 +150,12 @@ func TestParse(t *testing.T) {
assert.Equal(t, true, testDidPanic("NOT GONNA HAPPEN"))
for _, th := range testInputs {
ts = MustParse(th.in)
got := fmt.Sprintf("%v", ts.In(time.UTC))
assert.Equal(t, th.out, got, "Expected %q but got %q from %q", th.out, got, th.in)
}
// TODO: Is a utf8 date valid?
// ts = MustParse("2014-04\u221226")
// assert.Equal(t, "2014-04-26 00:00:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))