github.com/wangyougui/gf/v2@v2.6.5/os/gtime/gtime_z_unit_issue_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/wangyougui/gf. 6 7 package gtime_test 8 9 import ( 10 "testing" 11 12 "github.com/wangyougui/gf/v2/os/gtime" 13 "github.com/wangyougui/gf/v2/test/gtest" 14 ) 15 16 // https://github.com/wangyougui/gf/issues/1681 17 func Test_Issue1681(t *testing.T) { 18 gtest.C(t, func(t *gtest.T) { 19 t.Assert(gtime.New("2022-03-08T03:01:14-07:00").Local().Time, gtime.New("2022-03-08T10:01:14Z").Local().Time) 20 t.Assert(gtime.New("2022-03-08T03:01:14-08:00").Local().Time, gtime.New("2022-03-08T11:01:14Z").Local().Time) 21 t.Assert(gtime.New("2022-03-08T03:01:14-09:00").Local().Time, gtime.New("2022-03-08T12:01:14Z").Local().Time) 22 t.Assert(gtime.New("2022-03-08T03:01:14+08:00").Local().Time, gtime.New("2022-03-07T19:01:14Z").Local().Time) 23 }) 24 } 25 26 // https://github.com/wangyougui/gf/issues/2803 27 func Test_Issue2803(t *testing.T) { 28 gtest.C(t, func(t *gtest.T) { 29 newTime := gtime.New("2023-07-26").LayoutTo("2006-01") 30 t.Assert(newTime.Year(), 2023) 31 t.Assert(newTime.Month(), 7) 32 t.Assert(newTime.Day(), 1) 33 t.Assert(newTime.Hour(), 0) 34 t.Assert(newTime.Minute(), 0) 35 t.Assert(newTime.Second(), 0) 36 }) 37 }