From da541ab5510c8aa75b5268ddf653d560924a92b2 Mon Sep 17 00:00:00 2001 From: Oliver Steele Date: Mon, 10 Jul 2017 17:26:00 -0400 Subject: [PATCH] Remove dependency on strptime --- evaluator/parsedate.go | 13 ------------- evaluator/parsedate_test.go | 6 ------ 2 files changed, 19 deletions(-) diff --git a/evaluator/parsedate.go b/evaluator/parsedate.go index ddeafe4..41cf849 100644 --- a/evaluator/parsedate.go +++ b/evaluator/parsedate.go @@ -3,17 +3,10 @@ package evaluator import ( "reflect" "time" - - "github.com/jeffjen/datefmt" ) var zeroTime time.Time -// Strptime handles formats that time.Parse can't -var dateFormats = []string{ - "%Y-%m-%d %H:%M:%S %Z", // "2006-01-02 15:04:05 -7" -} - var dateLayouts = []string{ // from the Go library time.ANSIC, // "Mon Jan _2 15:04:05 2006" @@ -63,11 +56,5 @@ func ParseDate(s string) (time.Time, error) { return t, nil } } - for _, format := range dateFormats { - t, err := datefmt.Strptime(format, s) - if err == nil { - return t, nil - } - } return zeroTime, conversionError("", s, reflect.TypeOf(zeroTime)) } diff --git a/evaluator/parsedate_test.go b/evaluator/parsedate_test.go index b64d6b0..1cc872c 100644 --- a/evaluator/parsedate_test.go +++ b/evaluator/parsedate_test.go @@ -14,10 +14,4 @@ func TestConstant(t *testing.T) { dt, err = ParseDate("2017-07-09 10:40:00 UTC") require.NoError(t, err) require.Equal(t, timeMustParse("2017-07-09T10:40:00Z"), dt) - - // FIXME this actually ignores the tz. It's at least in the right ballpark; - // IMO better for content rendering than total failure. - dt, err = ParseDate("2017-07-09 15:30:00 -4") - require.NoError(t, err) - // require.Equal(t, timeMustParse("2017-07-09T15:30:00Z"), dt) }