Skip to content

Commit

Permalink
Remove dependency on strptime
Browse files Browse the repository at this point in the history
  • Loading branch information
osteele committed Jul 10, 2017
1 parent fdfc5d3 commit da541ab
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
13 changes: 0 additions & 13 deletions evaluator/parsedate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
}
6 changes: 0 additions & 6 deletions evaluator/parsedate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit da541ab

Please sign in to comment.