Time transform expression function accepts strings also
This commit is contained in:
@@ -173,6 +173,14 @@ func prepMod(base interface{}, mod interface{}) (*time.Time, int, error) {
|
||||
t = &auxt
|
||||
case *time.Time:
|
||||
t = auxt
|
||||
case string:
|
||||
tt, err := cast.ToTimeE(auxt)
|
||||
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
t = &tt
|
||||
default:
|
||||
return nil, 0, errors.New("unexpected input type")
|
||||
}
|
||||
|
||||
@@ -37,6 +37,13 @@ func Example_strftimeWithModTime() {
|
||||
// 1993-02-02T06:30:00
|
||||
}
|
||||
|
||||
func Example_strftimeWithStringValue() {
|
||||
eval(`strftime("1993-02-02T06:30:00", "%Y-%m-%dT%H:%M:%S")`, exampleTimeParams)
|
||||
|
||||
// output:
|
||||
// 1993-02-02T06:30:00
|
||||
}
|
||||
|
||||
func Example_parseISODate() {
|
||||
eval(`date("1993-02-02T06:00:00-05:00")`, nil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user