diff --git a/os/gtime/gtime_time.go b/os/gtime/gtime_time.go index cfe82bb43..3187a2d29 100644 --- a/os/gtime/gtime_time.go +++ b/os/gtime/gtime_time.go @@ -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 } diff --git a/os/gtime/gtime_z_unit_basic_test.go b/os/gtime/gtime_z_unit_basic_test.go index 7e458fd0b..7f2023e1f 100644 --- a/os/gtime/gtime_z_unit_basic_test.go +++ b/os/gtime/gtime_z_unit_basic_test.go @@ -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 ( diff --git a/os/gtime/gtime_z_unit_format_test.go b/os/gtime/gtime_z_unit_format_test.go index 95551ced9..fa79a5e7f 100644 --- a/os/gtime/gtime_z_unit_format_test.go +++ b/os/gtime/gtime_z_unit_format_test.go @@ -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 ( diff --git a/os/gtime/gtime_z_unit_time_test.go b/os/gtime/gtime_z_unit_time_test.go index 51be0b2b6..071844c46 100644 --- a/os/gtime/gtime_z_unit_time_test.go +++ b/os/gtime/gtime_z_unit_time_test.go @@ -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 (