-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_test.go
More file actions
53 lines (48 loc) · 1.15 KB
/
example_test.go
File metadata and controls
53 lines (48 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package localtimezone_test
import (
"fmt"
localtimezone "github.com/albertyw/localtimezone/v4"
)
func ExampleLocalTimeZone_GetZone() {
z := localtimezone.NewLocalTimeZone()
// Loading zones for the Alaska panhandle (overlaps America/Sitka and America/Vancouver)
p := localtimezone.Point{
Lon: -132.783555, Lat: 54.554439,
}
zones, err := z.GetZone(p)
if err != nil {
panic(err)
}
for _, zone := range zones {
fmt.Println(zone)
}
// Output:
// America/Sitka
// America/Vancouver
}
func ExampleLocalTimeZone_GetOneZone_sanFrancisco() {
z := localtimezone.NewLocalTimeZone()
// Loading zone for San Francisco, CA
p := localtimezone.Point{
Lon: -122.4194, Lat: 37.7749,
}
zone, err := z.GetOneZone(p)
if err != nil {
panic(err)
}
fmt.Println(zone)
// Output: America/Los_Angeles
}
func ExampleLocalTimeZone_GetOneZone_alaskaPanhandle() {
z := localtimezone.NewLocalTimeZone()
// Loading zone for the Alaska panhandle (overlaps America/Sitka and America/Vancouver)
p := localtimezone.Point{
Lon: -132.783555, Lat: 54.554439,
}
zone, err := z.GetOneZone(p)
if err != nil {
panic(err)
}
fmt.Println(zone)
// Output: America/Sitka
}