mirror of
https://github.com/araddon/dateparse.git
synced 2025-10-26 08:16:12 +08:00
More date formats closes #46
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user