Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-07-28 19:02:42 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-07-28 19:02:42 +0300
commitb5de37ee793c01f2acccdea7119be05c4182723f (patch)
tree3e756ee580e20c77a364a71231872e29b1c1dd23 /common
parentbf301daf158e5e9673ad5f457ea3a264315942b5 (diff)
Handle toml.LocalDate and toml.LocalDateTime in front matter
See #8801
Diffstat (limited to 'common')
-rw-r--r--common/htime/time.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/common/htime/time.go b/common/htime/time.go
index cd294b3a2..f5a19b961 100644
--- a/common/htime/time.go
+++ b/common/htime/time.go
@@ -17,6 +17,10 @@ import (
"strings"
"time"
+ "github.com/spf13/cast"
+
+ toml "github.com/pelletier/go-toml/v2"
+
"github.com/go-playground/locales"
)
@@ -125,3 +129,13 @@ func (f TimeFormatter) Format(t time.Time, layout string) string {
return s
}
+
+func ToTimeInDefaultLocationE(i interface{}, location *time.Location) (tim time.Time, err error) {
+ switch vv := i.(type) {
+ case toml.LocalDate:
+ return vv.AsTime(location), nil
+ case toml.LocalDateTime:
+ return vv.AsTime(location), nil
+ }
+ return cast.ToTimeInDefaultLocationE(i, location)
+}