timezone

package module
v0.0.0-...-4090b43 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2017 License: MIT Imports: 2 Imported by: 0

README

timezone Codeship Status for toldjuuso/timezone GoDoc

Timezone provides time.Location() compatible IANA timezone database locations and helper functions.

See examples and documentation in godoc.

License

MIT

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var Locations = []Timezone{}/* 584 elements not displayed */

Locations is a list of all IANA timezone locations and country codes.

Functions

func Offset

func Offset(loc string) (zone string, offset int, err error)

Offset returns the abbreviated name of the zone of l (such as "CET") and its offset in seconds east of UTC. The location should be valid IANA timezone location.

Example
zone, offset, _ := Offset("Europe/Helsinki")
fmt.Println(zone, offset)
Output:
EEST 10800

func ValidLocation

func ValidLocation(s string) bool

ValidLocation returns true if the given string can be found as a timezone location in the timezone.Locations array.

Example
fmt.Println(ValidLocation("Europe/Helsinki"))
Output:
true

Types

type Timezone

type Timezone struct {
	Location string
	Code     string
	Country  string
}

Timezone holds data gathered from CSV files on http://timezonedb.com/download.

func Code

func Code(c string) ([]Timezone, error)

Code returns all timezones with given country code. If none is found, returns an error.

func Country

func Country(c string) ([]Timezone, error)

Country returns all timezones with given country name. If none is found, returns an error.

Jump to

Keyboard shortcuts

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