zone

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package zone provides internal IANA timezone data and DST projection utilities.

Index

Constants

View Source
const CatalogVersion = "2025b"

CatalogVersion is the IANA tzdb version used to generate Zones.

Variables

View Source
var WindowsToIANA = map[string]string{}/* 139 elements not displayed */

WindowsToIANA maps Windows timezone names to CLDR's territory 001 IANA defaults.

View Source
var Zones = []string{}/* 419 elements not displayed */

Zones is a sorted list of IANA timezone identifiers embedded at build time. Callers must not mutate this slice.

Functions

func ResolveLocation

func ResolveLocation(id string) (string, *time.Location, bool)

ResolveLocation resolves an IANA name, case-insensitive IANA name, Windows timezone name into a canonical ID and location.

Types

type DSTStatus

type DSTStatus int

DSTStatus describes the DST classification of a projected local time.

const (
	// DSTNormal means the local time maps to exactly one UTC instant.
	DSTNormal DSTStatus = iota
	// DSTNonexistent means the local time falls in a spring-forward gap (no such wall time exists).
	DSTNonexistent
	// DSTAmbiguous means the local time falls in a fall-back overlap (two UTC instants map to it).
	DSTAmbiguous
)

type LocalTimeResult

type LocalTimeResult struct {
	// Status classifies the local time as normal, nonexistent, or ambiguous.
	Status DSTStatus
	// Times holds the matching instants in chronological order.
	Times []time.Time
}

LocalTimeResult holds the outcome of projecting a local wall-clock time into a timezone.

func ProjectLocalTime

func ProjectLocalTime(loc *time.Location, year int, month time.Month, day, hour, minute, second int) LocalTimeResult

ProjectLocalTime projects a local wall-clock time into loc and classifies the DST status.

Algorithm:

  1. Construct t = time.Date(year, month, day, hour, minute, second, 0, loc).
  2. Gap detection: if t's actual local components differ from requested, the wall time does not exist. Compare the date too, because some zones skip whole calendar days.
  3. Overlap detection: collect nearby UTC offsets and reproject the same wall time under each offset. This catches non-hour transitions such as Australia/Lord_Howe's 30-minute fall-back overlap without assuming every DST boundary is exactly one hour.
  4. Otherwise → DSTNormal with a single instant.

Directories

Path Synopsis
The geniana command generates the internal IANA timezone catalog.
The geniana command generates the internal IANA timezone catalog.
The genwindows command generates the Windows-to-IANA mapping from a pinned Unicode CLDR windowsZones.xml release.
The genwindows command generates the Windows-to-IANA mapping from a pinned Unicode CLDR windowsZones.xml release.

Jump to

Keyboard shortcuts

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