mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
tpl: Update Hugo time to support optional [LOCATION] parameter
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
b886fa46bb
commit
26eeb29147
@@ -34,15 +34,26 @@ func init() {
|
||||
//
|
||||
// If args are passed, call AsTime().
|
||||
|
||||
if len(args) == 0 {
|
||||
switch len(args) {
|
||||
case 0:
|
||||
return ctx
|
||||
}
|
||||
case 1:
|
||||
t, err := ctx.AsTime(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return t
|
||||
case 2:
|
||||
t, err := ctx.AsTime(args[0], args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return t
|
||||
|
||||
t, err := ctx.AsTime(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
// 3 or more arguments. Currently not supported.
|
||||
default:
|
||||
return "Invalid arguments supplied to `time`. Refer to time documentation: https://gohugo.io/functions/time/"
|
||||
}
|
||||
return t
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user