Skip to content

Commit

Permalink
fix(manager): timezone issue of status test
Browse files Browse the repository at this point in the history
  • Loading branch information
bigeagle committed Apr 30, 2016
1 parent 42c645a commit d198137
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions manager/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions manager/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit d198137

Please sign in to comment.