From d1981379a4ac655e91fd31530ab7f7e5b3d500d0 Mon Sep 17 00:00:00 2001 From: bigeagle Date: Fri, 29 Apr 2016 07:59:54 +0800 Subject: [PATCH] fix(manager): timezone issue of status test --- manager/status.go | 4 ++-- manager/status_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manager/status.go b/manager/status.go index 8df2b3c..31bd1d5 100644 --- a/manager/status.go +++ b/manager/status.go @@ -13,11 +13,11 @@ type textTime struct { } func (t textTime) MarshalJSON() ([]byte, error) { - return json.Marshal(t.Format("2006-01-02 15:04:05")) + return json.Marshal(t.Format("2006-01-02 15:04:05 -0700")) } func (t *textTime) UnmarshalJSON(b []byte) error { s := string(b) - t2, err := time.ParseInLocation(`"2006-01-02 15:04:05"`, s, time.Local) + t2, err := time.Parse(`"2006-01-02 15:04:05 -0700"`, s) *t = textTime{t2} return err } diff --git a/manager/status_test.go b/manager/status_test.go index 2ca0f1e..9cd046a 100644 --- a/manager/status_test.go +++ b/manager/status_test.go @@ -12,7 +12,7 @@ import ( func TestStatus(t *testing.T) { Convey("status json ser-de should work", t, func() { - tz := "Asia/Shanghai" + tz := "Asia/Tokyo" loc, err := time.LoadLocation(tz) So(err, ShouldBeNil) t := time.Date(2016, time.April, 16, 23, 8, 10, 0, loc) @@ -27,7 +27,7 @@ func TestStatus(t *testing.T) { b, err := json.Marshal(m) So(err, ShouldBeNil) - // fmt.Println(string(b)) + //fmt.Println(string(b)) var m2 webMirrorStatus err = json.Unmarshal(b, &m2) So(err, ShouldBeNil)