mirror of
https://gitee.com/johng/gf
synced 2026-07-03 11:51:04 +08:00
fix issue in cycle import for gtime
This commit is contained in:
@ -8,7 +8,6 @@ package gtime
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -196,12 +195,12 @@ func (t *Time) Truncate(d time.Duration) *Time {
|
||||
|
||||
// MarshalJSON implements the interface MarshalJSON for json.Marshal.
|
||||
func (t *Time) MarshalJSON() ([]byte, error) {
|
||||
return gconv.UnsafeStrToBytes(`"` + t.String() + `"`), nil
|
||||
return []byte(`"` + t.String() + `"`), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
|
||||
func (t *Time) UnmarshalJSON(b []byte) error {
|
||||
newTime, err := StrToTime(gconv.UnsafeBytesToStr(bytes.Trim(b, `"`)))
|
||||
newTime, err := StrToTime(string(bytes.Trim(b, `"`)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package gtime_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package gtime_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package gtime_test
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user