summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2021-08-10 13:21:49 +0200
committerBjørn Erik Pedersen <[email protected]>2021-08-10 13:21:49 +0200
commitabd969a670852f9ed57c1a26434445aa985706fe (patch)
tree3995a81a85377b20da92aa33b9d1a536699311c9
parent3e11072892ca31bb76980ee38890a4bd92d83dfd (diff)
downloadhugo-abd969a670852f9ed57c1a26434445aa985706fe.tar.gz
hugo-abd969a670852f9ed57c1a26434445aa985706fe.zip
Revert "tpl/time: Handle nil values in time.AsTime"
This reverts commit 3e11072892ca31bb76980ee38890a4bd92d83dfd.
-rw-r--r--tpl/time/time.go5
-rw-r--r--tpl/time/time_test.go5
2 files changed, 1 insertions, 9 deletions
diff --git a/tpl/time/time.go b/tpl/time/time.go
index f10f3a23a..b89dcfe09 100644
--- a/tpl/time/time.go
+++ b/tpl/time/time.go
@@ -19,8 +19,6 @@ import (
"time"
_time "time"
- "github.com/gohugoio/hugo/common/hreflect"
-
"github.com/gohugoio/hugo/common/htime"
"github.com/gohugoio/locales"
@@ -45,9 +43,6 @@ type Namespace struct {
// AsTime converts the textual representation of the datetime string into
// a time.Time interface.
func (ns *Namespace) AsTime(v interface{}, args ...interface{}) (interface{}, error) {
- if !hreflect.IsTruthful(v) {
- return time.Time{}, nil
- }
loc := ns.location
if len(args) > 0 {
locStr, err := cast.ToStringE(args[0])
diff --git a/tpl/time/time_test.go b/tpl/time/time_test.go
index c699f200b..f6e4d0f72 100644
--- a/tpl/time/time_test.go
+++ b/tpl/time/time_test.go
@@ -29,7 +29,7 @@ func TestTimeLocation(t *testing.T) {
for i, test := range []struct {
name string
- value interface{}
+ value string
location interface{}
expect interface{}
}{
@@ -39,9 +39,6 @@ func TestTimeLocation(t *testing.T) {
{"New York EST", "2020-01-20", "America/New_York", "2020-01-20 00:00:00 -0500 EST"},
{"Empty location, time", "2020-10-20 20:33:59", "", "2020-10-20 20:33:59 +0000 UTC"},
{"New York, time", "2020-10-20 20:33:59", "America/New_York", "2020-10-20 20:33:59 -0400 EDT"},
- {"Nil value", nil, "", "0001-01-01 00:00:00 +0000"},
- {"Empty value", "", "", "0001-01-01 00:00:00 +0000"},
-
// The following have an explicit offset specified. In this case, it overrides timezone
{"Offset minus 0700, empty location", "2020-09-23T20:33:44-0700", "", "2020-09-23 20:33:44 -0700 -0700"},
{"Offset plus 0200, empty location", "2020-09-23T20:33:44+0200", "", "2020-09-23 20:33:44 +0200 +0200"},