summaryrefslogtreecommitdiffstats
path: root/tpl/time/time_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-08-09 18:44:35 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-08-09 18:44:35 +0200
commit3e11072892ca31bb76980ee38890a4bd92d83dfd (patch)
tree2743b3090006a6d2073efa7476a78b962814361a /tpl/time/time_test.go
parent9bba9a3a98fa268391597d8d7a52112fb401d952 (diff)
tpl/time: Handle nil values in time.AsTime
Closes #8865
Diffstat (limited to 'tpl/time/time_test.go')
-rw-r--r--tpl/time/time_test.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/tpl/time/time_test.go b/tpl/time/time_test.go
index f6e4d0f72..c699f200b 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 string
+ value interface{}
location interface{}
expect interface{}
}{
@@ -39,6 +39,9 @@ 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"},