diff options
| author | Venil Noronha <veniln@vmware.com> | 2018-08-30 12:44:54 -0600 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-08-30 19:38:38 +0000 |
| commit | e84409ac95d5ed4a9113128c72d8f930f034aebf (patch) | |
| tree | a8e08dfe570ef17c7e3bf4d6e7cb8fd3acf3041c /src/time | |
| parent | a2a8396f530a481ef2d2ad289bee1c741bc7f34e (diff) | |
| download | go-e84409ac95d5ed4a9113128c72d8f930f034aebf.tar.xz | |
time: add example for LoadLocation
Change-Id: I8e55e9397eb6844b5856f8bde9c26185c446a80e
Reviewed-on: https://go-review.googlesource.com/132238
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/time')
| -rw-r--r-- | src/time/example_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/time/example_test.go b/src/time/example_test.go index 494a416802..7e303ac5a0 100644 --- a/src/time/example_test.go +++ b/src/time/example_test.go @@ -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()) |
