README
Package tz provides a wrapper for time.Location
with additional information
about timezones.
Every timezone is represented by a zone name (Europe/Amsterdam
) and a country
(NL
). The rationale for this is mostly a user interface one: it makes more
sense to display a list of countries first and then a list of timezones, instead
of just presenting a huge list of timezones.
For example, my current TZ is Asia/Makkasar (WITA), but it's much easier to select "Indonesia" from a list, and then choose one of the four timezones in Indonesia:
Indonesia: Asia/Jayapura (WIT) – New Guinea (West Papua / Irian Jaya); Malukus/Moluccas
Indonesia: Asia/Makassar (WITA) – Borneo (east, south); Sulawesi/Celebes, Bali, Nusa Tengarra; Timor (west)
Indonesia: Asia/Pontianak (WIB) – Borneo (west, central)
Indonesia: Asia/Jakarta (WIB) – Java, Sumatra
We need to store both to make sure people who fill in "Isle of Man, Europe/London" aren't shown "you selected Britain, Europe/London" when they revisit a settings page.
Documentation
Overview ¶
Package tz contains timezone lists.
Index ¶
- Variables
- type Zone
- func (t *Zone) Display() string
- func (t *Zone) Loc() *time.Location
- func (t Zone) MarshalText() ([]byte, error)
- func (t *Zone) Offset() int
- func (t *Zone) OffsetDisplay() string
- func (t *Zone) OffsetRFC3339() string
- func (t *Zone) Scan(v interface{}) error
- func (t *Zone) String() string
- func (t *Zone) UnmarshalText(v []byte) error
- func (t Zone) Value() (driver.Value, error)
Constants ¶
Variables ¶
var UTC = &Zone{CountryCode: "", Zone: "UTC", Abbr: []string{"UTC"}, CountryName: "UTC", Comments: "", Location: time.UTC}
UTC timezone.
var Zones = []*Zone{}/* 429 elements not displayed */
Zones is a list of all timezones by country.
Functions ¶
Types ¶
type Zone ¶
type Zone struct { *time.Location CountryCode string // ID Zone string // Asia/Makassar Abbr []string // WITA – the correct abbreviation may change depending on the time of year (i.e. CET and CEST, depending on DST). CountryName string // Indonesia Comments string // Borneo (east, south); Sulawesi/Celebes, Bali, Nusa Tengarra; Timor (west) // contains filtered or unexported fields }
Zone represents a time zone.
func New ¶
New timezone from country code and zone name. The country code is only informative, and may be blank or wrong, in which case it will load the first zone found.
func (Zone) MarshalText ¶
MarshalText converts the data to a human readable representation.
func (*Zone) OffsetDisplay ¶
OffsetDisplay gets the offset as a human readable string: "UTC +8:00", "UTC -7:30", "UTC".
Note that this displays the offset that is currently valid. For example Europe/Berlin may be +0100 or +0200, depending on whether DST is in effect.
func (*Zone) OffsetRFC3339 ¶
OffsetRFC3339 gets the offset as a RFC3339 string: "+08:00", "-07:30", "UTC".
Note that this displays the offset that is currently valid. For example Europe/Berlin may be +0100 or +0200, depending on whether DST is in effect.
func (*Zone) UnmarshalText ¶
UnmarshalText parses text in to the Go data structure.