]> Cypherpunks repositories - gostls13.git/commitdiff
time: add example for LoadLocation
authorVenil Noronha <veniln@vmware.com>
Thu, 30 Aug 2018 18:44:54 +0000 (12:44 -0600)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 30 Aug 2018 19:38:38 +0000 (19:38 +0000)
Change-Id: I8e55e9397eb6844b5856f8bde9c26185c446a80e
Reviewed-on: https://go-review.googlesource.com/132238
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/time/example_test.go

index 494a41680253d2f031679ffca74c1112421959b1..7e303ac5a0016301298da54c2982f1038f6a76dd 100644 (file)
@@ -429,6 +429,17 @@ func ExampleTime_Truncate() {
        // t.Truncate(10m0s) = 12:10:00
 }
 
+func ExampleLoadLocation() {
+       location, err := time.LoadLocation("America/Los_Angeles")
+       if err != nil {
+               panic(err)
+       }
+
+       timeInUTC := time.Date(2018, 8, 30, 12, 0, 0, 0, time.UTC)
+       fmt.Println(timeInUTC.In(location))
+       // Output: 2018-08-30 05:00:00 -0700 PDT
+}
+
 func ExampleLocation() {
        // China doesn't have daylight saving. It uses a fixed 8 hour offset from UTC.
        secondsEastOfUTC := int((8 * time.Hour).Seconds())