Open puc9 opened 9 months ago
i encoutered the same error, pls help
pkg/tplfunc/date.go
func FormatDate() Func {
return func(funcMap template.FuncMap) {
funcMap["formatDate"] = func(args ...any) string {
switch len(args) {
case 0:
panic("formatDate() requires at least 1 argument")
case 1:
switch v := args[0].(type) {
case int, int64:
return time.Unix(v.(int64), 0).Format("20060102150405")
default:
panic("formatDate() requires an int or int64 as its first argument")
}
case 2:
switch v := args[0].(type) {
case int, int64:
return time.Unix(v.(int64), 0).Format(args[1].(string))
default:
panic("formatDate() requires an int or int64 as its first argument")
}
default:
panic("formatDate() requires at most 2 arguments")
}
}
}
}
I met with this error.
Error: callback:
github.com/gotd/td/telegram.(*Client).Run.func3
github.com/gotd/td@v0.105.0/telegram/connect.go:151
- parse template:
github.com/iyear/tdl/app/dl.newIter
github.com/iyear/tdl/app/dl/iter.go:67
- template: dl:1: bad number syntax: "2006-01"
Describe the bug
Using this as part of the template
{{ formatDate .MessageDate "2006-01-02_15-04-05" }}
fails with:To Reproduce
Run:
Expected behavior
Should successfully format the MessageDate
Version
Version: 0.16.0 Commit: 0e1ce1d Date: 2024-02-15T02:51:19Z
go1.21.7 windows/amd64
Which OS are you running tdl on?
Windows
Additional context
No response