2019-02-02 16:18:25 +08:00
|
|
|
// Copyright 2018 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
2019-01-15 21:54:34 +08:00
|
|
|
//
|
|
|
|
|
// 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,
|
2019-02-02 16:18:25 +08:00
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
2019-01-15 21:54:34 +08:00
|
|
|
|
|
|
|
|
package gconv_test
|
|
|
|
|
|
|
|
|
|
import (
|
2019-06-19 09:06:52 +08:00
|
|
|
"testing"
|
|
|
|
|
"time"
|
2019-07-29 21:01:19 +08:00
|
|
|
|
|
|
|
|
"github.com/gogf/gf/os/gtime"
|
|
|
|
|
"github.com/gogf/gf/test/gtest"
|
|
|
|
|
"github.com/gogf/gf/util/gconv"
|
2019-01-15 21:54:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test_Time(t *testing.T) {
|
2020-03-19 22:56:12 +08:00
|
|
|
gtest.C(t, func(t *gtest.T) {
|
2019-06-01 00:02:05 +08:00
|
|
|
t1 := "2011-10-10 01:02:03.456"
|
2020-03-19 22:56:12 +08:00
|
|
|
t.AssertEQ(gconv.GTime(t1), gtime.NewFromStr(t1))
|
|
|
|
|
t.AssertEQ(gconv.Time(t1), gtime.NewFromStr(t1).Time)
|
|
|
|
|
t.AssertEQ(gconv.Duration(100), 100*time.Nanosecond)
|
2019-06-01 00:02:05 +08:00
|
|
|
})
|
2019-01-15 21:54:34 +08:00
|
|
|
}
|