Handle toml.LocalDate and toml.LocalDateTime in front matter

See #8801
This commit is contained in:
Bjørn Erik Pedersen
2021-07-28 18:02:42 +02:00
parent bf301daf15
commit b5de37ee79
4 changed files with 21 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/common/htime"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/common/loggers"
@@ -130,7 +131,7 @@ func dateAndSlugFromBaseFilename(location *time.Location, name string) (time.Tim
return time.Time{}, ""
}
d, err := cast.ToTimeInDefaultLocationE(withoutExt[:10], location)
d, err := htime.ToTimeInDefaultLocationE(withoutExt[:10], location)
if err != nil {
return time.Time{}, ""
}
@@ -371,7 +372,7 @@ func (f *frontmatterFieldHandlers) newDateFieldHandler(key string, setter func(d
return false, nil
}
date, err := cast.ToTimeInDefaultLocationE(v, d.Location)
date, err := htime.ToTimeInDefaultLocationE(v, d.Location)
if err != nil {
return false, nil
}