wtz

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2020 License: BSD-3-Clause Imports: 2 Imported by: 8

README

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.

Documentation

Overview

Package wtz is a portable library to handle the time zone names used in Windows. You can translate them to/from the IANA (Go native) time zone names. The mapping table is based on Unicode CLDR.

Index

Constants

This section is empty.

Variables

View Source
var OffsetToWindowsMap = map[int]string{
	-43200: "Dateline Standard Time",
	-39600: "UTC-11",
	-36000: "Hawaiian Standard Time",
	-34200: "Marquesas Standard Time",
	-32400: "UTC-09",
	-28800: "UTC-08",
	-25200: "US Mountain Standard Time",
	-21600: "Central America Standard Time",
	-18000: "SA Pacific Standard Time",
	-14400: "SA Western Standard Time",
	-10800: "SA Eastern Standard Time",
	-9000:  "Newfoundland Standard Time",
	-7200:  "UTC-02",
	-3600:  "Cape Verde Standard Time",
	0:      "UTC",
	3600:   "W. Central Africa Standard Time",
	7200:   "South Africa Standard Time",
	10800:  "E. Africa Standard Time",
	14400:  "Arabian Standard Time",
	16200:  "Afghanistan Standard Time",
	18000:  "West Asia Standard Time",
	19800:  "Sri Lanka Standard Time",
	20700:  "Nepal Standard Time",
	21600:  "Central Asia Standard Time",
	23400:  "Myanmar Standard Time",
	25200:  "SE Asia Standard Time",
	28800:  "Singapore Standard Time",
	31500:  "Aus Central W. Standard Time",
	32400:  "Tokyo Standard Time",
	34200:  "AUS Central Standard Time",
	36000:  "West Pacific Standard Time",
	37800:  "Lord Howe Standard Time",
	39600:  "Central Pacific Standard Time",
	43200:  "UTC+12",
	45900:  "Chatham Islands Standard Time",
	46800:  "UTC+13",
	50400:  "Line Islands Standard Time",
}

OffsetToWindowsMap translates from time zone offset seconds to Windows zone name.

View Source
var UnixToWindowsMap = map[string]string{}/* 459 elements not displayed */

UnixToWindowsMap is the time zone translation map from Unix to Windows.

View Source
var WindowsToUnixMap = map[string]string{}/* 137 elements not displayed */

WindowsToUnixMap is the time zone translation map from Windows to Unix.

Functions

func LoadLocation

func LoadLocation(name string) (*time.Location, error)

LoadLocation is an alias of NameToLocation

func LocationToName

func LocationToName(loc *time.Location) (string, error)

LocationToName converts Location to Windows zone name

func NameToLocation

func NameToLocation(name string) (*time.Location, error)

NameToLocation converts Windows zone name to Location

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL