https://github.com/yaegashi/wtz.go
Windows Time Zone Library for Go
https://github.com/yaegashi/wtz.go
golang timezone windows
Last synced: 10 months ago
JSON representation
Windows Time Zone Library for Go
- Host: GitHub
- URL: https://github.com/yaegashi/wtz.go
- Owner: yaegashi
- License: bsd-3-clause
- Created: 2020-04-30T11:06:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-30T14:37:13.000Z (about 6 years ago)
- Last Synced: 2025-03-30T11:02:46.561Z (over 1 year ago)
- Topics: golang, timezone, windows
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wtz.go
[](https://pkg.go.dev/github.com/yaegashi/wtz.go)
## Introduction
wtz.go is a Go library to portablly handle the time zone names used in Windows.
They sometimes appear to you outside the Windows environment,
for example, when manipulating Office 365 calendar events
with [msgraph.go](https://github.com/yaegashi/msgraph.go)
(see [dateTimeTimeZone resource type](https://docs.microsoft.com/en-us/graph/api/resources/datetimetimezone?view=graph-rest-1.0)).
wtz.go helps you with translating them to/from [time.Location](https://golang.org/pkg/time/#Location) with IANA time zone names.
## Example
Playground: https://play.golang.org/p/l9CeGUXNwZP
```go
package main
import (
"fmt"
"github.com/yaegashi/wtz.go"
"time"
)
func main() {
var n string
var l *time.Location
n = "Tokyo Standard Time"
l, _ = wtz.LoadLocation(n)
fmt.Printf("%v -> %v\n", n, l)
l, _ = time.LoadLocation("America/Los_Angeles")
n, _ = wtz.LocationToName(l)
fmt.Printf("%v -> %v\n", l, n)
}
```
## Acknowledgement
[The mapping table](wtz_maps.go) is based on
[windowsZones.xml](https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml)
from [Unicode CLDR](http://cldr.unicode.org/).
[The table generator](gen/genmaps.go) is inspired by [genzabbrs.go](https://golang.org/src/time/genzabbrs.go).