Created
September 6, 2021 13:59
-
-
Save j2gg0s/023976a876f28b7ecdf13c9fdec36177 to your computer and use it in GitHub Desktop.
magic with go's time with default location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "testing" | |
| "time" | |
| "github.com/stretchr/testify/require" | |
| ) | |
| func TestTimeLocation(t *testing.T) { | |
| x, y := time.Unix(0, 0), time.Unix(0, 0) | |
| require.Equal(t, x, y) | |
| x.String() | |
| require.NotEqual(t, x, y) | |
| } | |
| func ExampleTimeLocation() { | |
| st := time.Unix(0, 0) | |
| locValue := *st.Location() | |
| fmt.Println(locValue) | |
| fmt.Printf("%v\n", st) | |
| fmt.Printf("%v\n", *st.Location()) | |
| // Output: { [] [] 0 0 <nil>} | |
| // 1970-01-01 08:00:00 +0800 CST | |
| // {Local [{LMT 29143 false} {CDT 32400 true} {CST 28800 false}] [{-2177481943 2 false false} {-1600675200 1 false false} {-1585904400 2 false false} {-933667200 1 false false} {-922093200 2 false false} {-908870400 1 false false} {-888829200 2 false false} {-881049600 1 false false} {-767869200 2 false false} {-745833600 1 false false} {-733827600 2 false false} {-716889600 1 false false} {-699613200 2 false false} {-683884800 1 false false} {-670669200 2 false false} {-652348800 1 false false} {-650019600 2 false false} {515527200 1 false false} {527014800 2 false false} {545162400 1 false false} {558464400 2 false false} {577216800 1 false false} {589914000 2 false false} {608666400 1 false false} {621968400 2 false false} {640116000 1 false false} {653418000 2 false false} {671565600 1 false false} {684867600 2 false false}] CST-8 9223372036854775807 9223372036854775807 0xc00006a2e0} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment