aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/time
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2022-04-30 18:12:08 +0200
committerBjørn Erik Pedersen <[email protected]>2022-05-06 19:43:22 +0200
commit6eea32bd6bc8e7a7dd07a8cb6a8343ae2c74aba0 (patch)
treedc9b14069f5e983942ac53c6f5e6d8629a5c269e /tpl/time
parenta6d545854a670356e93cd48e55de6e81233d68cb (diff)
downloadhugo-6eea32bd6bc8e7a7dd07a8cb6a8343ae2c74aba0.tar.gz
hugo-6eea32bd6bc8e7a7dd07a8cb6a8343ae2c74aba0.zip
tpl: Improve godoc
Diffstat (limited to 'tpl/time')
-rw-r--r--tpl/time/time.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/tpl/time/time.go b/tpl/time/time.go
index f82d63c44..623b7206a 100644
--- a/tpl/time/time.go
+++ b/tpl/time/time.go
@@ -57,9 +57,8 @@ func (ns *Namespace) AsTime(v any, args ...any) (any, error) {
}
-// Format converts the textual representation of the datetime string into
-// the other form or returns it of the time.Time value. These are formatted
-// with the layout string
+// Format converts the textual representation of the datetime string in v into
+// time.Time if needed and formats it with the given layout.
func (ns *Namespace) Format(layout string, v any) (string, error) {
t, err := htime.ToTimeInDefaultLocationE(v, ns.location)
if err != nil {
@@ -74,19 +73,19 @@ func (ns *Namespace) Now() _time.Time {
return _time.Now()
}
-// ParseDuration parses a duration string.
+// ParseDuration parses the duration string s.
// A duration string is a possibly signed sequence of
// decimal numbers, each with optional fraction and a unit suffix,
// such as "300ms", "-1.5h" or "2h45m".
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
// See https://golang.org/pkg/time/#ParseDuration
-func (ns *Namespace) ParseDuration(in any) (_time.Duration, error) {
- s, err := cast.ToStringE(in)
+func (ns *Namespace) ParseDuration(s any) (_time.Duration, error) {
+ ss, err := cast.ToStringE(s)
if err != nil {
return 0, err
}
- return _time.ParseDuration(s)
+ return _time.ParseDuration(ss)
}
var durationUnits = map[string]_time.Duration{