3
0

Time transform expression function accepts strings also

This commit is contained in:
Peter Grlica
2022-04-08 11:48:18 +02:00
parent 56af630c05
commit 5b40f78756
2 changed files with 15 additions and 0 deletions
+8
View File
@@ -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")
}
+7
View File
@@ -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)