Skip to content

yaegashi/wtz.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wtz.go

go.dev

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 (see dateTimeTimeZone resource type). wtz.go helps you with translating them to/from time.Location with IANA time zone names.

Example

Playground: https://play.golang.org/p/l9CeGUXNwZP

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 is based on windowsZones.xml from Unicode CLDR. The table generator is inspired by genzabbrs.go.