diff --git a/json.go b/json.go index 29e53214..0d9393f8 100644 --- a/json.go +++ b/json.go @@ -87,7 +87,7 @@ func (t DateTime) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface json.Unmarshal for DateTime struct. // 实现 UnmarshalJSON 接口 func (t *DateTime) UnmarshalJSON(b []byte) error { - c := ParseByLayout(string(bytes.Trim(b, `"`)), DateTimeLayout, t.loc.String()) + c := ParseByLayout(string(bytes.Trim(b, `"`)), DateTimeLayout, t.Location()) if c.Error == nil { *t = DateTime{c} } @@ -109,7 +109,7 @@ func (t DateTimeMilli) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface json.Unmarshal for DateTimeMilli struct. // 实现 UnmarshalJSON 接口 func (t *DateTimeMilli) UnmarshalJSON(b []byte) error { - c := ParseByLayout(string(bytes.Trim(b, `"`)), DateTimeMilliLayout, t.loc.String()) + c := ParseByLayout(string(bytes.Trim(b, `"`)), DateTimeMilliLayout, t.Location()) if c.Error == nil { *t = DateTimeMilli{c} } @@ -131,7 +131,7 @@ func (t DateTimeMicro) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface json.Unmarshal for DateTimeMicro struct. // 实现 UnmarshalJSON 接口 func (t *DateTimeMicro) UnmarshalJSON(b []byte) error { - c := ParseByLayout(string(bytes.Trim(b, `"`)), DateTimeMicroLayout, t.loc.String()) + c := ParseByLayout(string(bytes.Trim(b, `"`)), DateTimeMicroLayout, t.Location()) if c.Error == nil { *t = DateTimeMicro{c} } @@ -153,7 +153,7 @@ func (t DateTimeNano) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface json.Unmarshal for DateTimeNano struct. // 实现 UnmarshalJSON 接口 func (t *DateTimeNano) UnmarshalJSON(b []byte) error { - c := ParseByLayout(string(bytes.Trim(b, `"`)), DateTimeNanoLayout, t.loc.String()) + c := ParseByLayout(string(bytes.Trim(b, `"`)), DateTimeNanoLayout, t.Location()) if c.Error == nil { *t = DateTimeNano{c} } @@ -175,7 +175,7 @@ func (t Date) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface json.Unmarshal for Date struct. // 实现 UnmarshalJSON 接口 func (t *Date) UnmarshalJSON(b []byte) error { - c := ParseByLayout(string(bytes.Trim(b, `"`)), DateLayout, t.loc.String()) + c := ParseByLayout(string(bytes.Trim(b, `"`)), DateLayout, t.Location()) if c.Error == nil { *t = Date{c} } @@ -197,7 +197,7 @@ func (t DateMilli) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface json.Unmarshal for DateMilli struct. // 实现 UnmarshalJSON 接口 func (t *DateMilli) UnmarshalJSON(b []byte) error { - c := ParseByLayout(string(bytes.Trim(b, `"`)), DateMilliLayout, t.loc.String()) + c := ParseByLayout(string(bytes.Trim(b, `"`)), DateMilliLayout, t.Location()) if c.Error == nil { *t = DateMilli{c} } @@ -219,7 +219,7 @@ func (t DateMicro) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface json.Unmarshal for DateMicro struct. // 实现 UnmarshalJSON 接口 func (t *DateMicro) UnmarshalJSON(b []byte) error { - c := ParseByLayout(string(bytes.Trim(b, `"`)), DateMicroLayout, t.loc.String()) + c := ParseByLayout(string(bytes.Trim(b, `"`)), DateMicroLayout, t.Location()) if c.Error == nil { *t = DateMicro{c} } @@ -241,7 +241,7 @@ func (t DateNano) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface json.Unmarshal for DateNano struct. // 实现 UnmarshalJSON 接口 func (t *DateNano) UnmarshalJSON(b []byte) error { - c := ParseByLayout(string(bytes.Trim(b, `"`)), DateNanoLayout, t.loc.String()) + c := ParseByLayout(string(bytes.Trim(b, `"`)), DateNanoLayout, t.Location()) if c.Error == nil { *t = DateNano{c} }