"strings"
"time"
+ "github.com/spf13/cast"
+
+ toml "github.com/pelletier/go-toml/v2"
+
"github.com/go-playground/locales"
)
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)
+}
if quoted {
return fmt.Sprintf("%q", d)
}
+
return d
}
"short-date-yaml-qouted.nn.md", createPageContent(pageTemplYaml, shortDateTempl, true),
"long-date-yaml-unqouted.en.md", createPageContent(pageTemplYaml, longDateTempl, false),
"long-date-yaml-unqouted.nn.md", createPageContent(pageTemplYaml, longDateTempl, false),
-
// TOML
"short-date-toml-unqouted.en.md", createPageContent(pageTemplTOML, shortDateTempl, false),
"short-date-toml-unqouted.nn.md", createPageContent(pageTemplTOML, shortDateTempl, false),
// TOML
// These fails: TOML (Burnt Sushi) defaults to local timezone.
// TODO(bep) check go-toml
- // b.AssertFileContent("public/en/short-date-toml-unqouted/index.html", expectShortDateEn)
- // b.AssertFileContent("public/nn/short-date-toml-unqouted/index.html", expectShortDateNn)
+ b.AssertFileContent("public/en/short-date-toml-unqouted/index.html", expectShortDateEn)
+ b.AssertFileContent("public/nn/short-date-toml-unqouted/index.html", expectShortDateNn)
b.AssertFileContent("public/en/short-date-toml-qouted/index.html", expectShortDateEn)
b.AssertFileContent("public/nn/short-date-toml-qouted/index.html", expectShortDateNn)
"strings"
"time"
+ "github.com/gohugoio/hugo/common/htime"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/common/loggers"
return time.Time{}, ""
}
- d, err := cast.ToTimeInDefaultLocationE(withoutExt[:10], location)
+ d, err := htime.ToTimeInDefaultLocationE(withoutExt[:10], location)
if err != nil {
return time.Time{}, ""
}
return false, nil
}
- date, err := cast.ToTimeInDefaultLocationE(v, d.Location)
+ date, err := htime.ToTimeInDefaultLocationE(v, d.Location)
if err != nil {
return false, nil
}