From afe699793b6c03b41c38ba8bb9386b7e44977b5c Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Mon, 26 Jun 2017 03:38:45 -0600 Subject: [PATCH] Complete the testing for decoding datetime with UTC offset Kudos to @nathany who wrote: > It looks like the simple struct below should include a few more fields > and answer should do a comparison of these to complete the testing. in his code review for Pull Request #182. --- decode_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/decode_test.go b/decode_test.go index f760029f..95bc987f 100644 --- a/decode_test.go +++ b/decode_test.go @@ -16,8 +16,8 @@ age = 250 andrew = "gallant" kait = "brady" now = 1987-07-05T05:45:00Z -nowCanada = 2017-06-22T02:14:36-06:00 -nowChina = 2017-06-22T16:15:21+08:00 +nowEast = 2017-06-22T16:15:21+08:00 +nowWest = 2017-06-22T02:14:36-06:00 yesOrNo = true pi = 3.14 colors = [ @@ -40,6 +40,8 @@ cauchy = "cat 2" Pi float64 YesOrNo bool Now time.Time + NowEast time.Time + NowWest time.Time Andrew string Kait string My map[string]cats @@ -55,11 +57,21 @@ cauchy = "cat 2" if err != nil { panic(err) } + nowEast, err := time.Parse("2006-01-02T15:04:05-07:00", "2017-06-22T16:15:21+08:00") + if err != nil { + panic(err) + } + nowWest, err := time.Parse("2006-01-02T15:04:05-07:00", "2017-06-22T02:14:36-06:00") + if err != nil { + panic(err) + } var answer = simple{ Age: 250, Andrew: "gallant", Kait: "brady", Now: now, + NowEast: nowEast, + NowWest: nowWest, YesOrNo: true, Pi: 3.14, Colors: [][]string{