diff --git a/pkg/tplfunc/date.go b/pkg/tplfunc/date.go index f65c025..e2f6e81 100644 --- a/pkg/tplfunc/date.go +++ b/pkg/tplfunc/date.go @@ -3,6 +3,8 @@ package tplfunc import ( "text/template" "time" + + "github.com/spf13/cast" ) var Date = []Func{Now(), FormatDate()} @@ -22,9 +24,9 @@ func FormatDate() Func { case 0: panic("formatDate() requires at least 1 argument") case 1: - return time.Unix(int64(args[0].(int)), 0).Format("20060102150405") + return time.Unix(cast.ToInt64(args[0]), 0).Format("20060102150405") case 2: - return time.Unix(int64(args[0].(int)), 0).Format(args[1].(string)) + return time.Unix(cast.ToInt64(args[0]), 0).Format(args[1].(string)) default: panic("formatDate() requires at most 2 arguments") }