fix(manager): timezone issue of status test

This commit is contained in:
bigeagle 2016-04-29 07:59:54 +08:00
parent 42c645a736
commit d1981379a4
No known key found for this signature in database
GPG Key ID: 9171A4571C27920A
2 changed files with 4 additions and 4 deletions

View File

@ -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
}

View File

@ -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)