1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-30 06:08:57 +01:00

Remove dependency on strptime

This commit is contained in:
Oliver Steele 2017-07-10 17:26:00 -04:00
parent fdfc5d3a81
commit da541ab551
2 changed files with 0 additions and 19 deletions

View File

@ -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))
}

View File

@ -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)
}