Documentation
¶
Overview ¶
Package timezones resolves IANA zone identifiers, mirroring lib/tasks/timezones.rb as far as the read path and the probe need it: the identifier gate, the detection precedence, and the tzdb self-report.
Index ¶
- Constants
- func Ambiguous(year int, month time.Month, day, hour, minute int, location *time.Location) bool
- func Detect(tz string, localtime string) (string, string, bool)
- func EarliestOn(year int, month time.Month, day int, location *time.Location) (time.Time, error)
- func FirstValidLocalAfter(year int, month time.Month, day, hour, minute int, location *time.Location) (string, bool)
- func Get(identifier string) (string, error)
- func InstantsFor(year int, month time.Month, day, hour, minute int, location *time.Location) []time.Time
- func Load(identifier string) (*time.Location, error)
- func LocalTime(instant time.Time, location *time.Location) time.Time
- func TZDBVersion() string
- func UTCFor(year int, month time.Month, day, hour, minute int, location *time.Location, ...) (time.Time, error)
- type Error
- type NonexistentLocalTime
Constants ¶
const Fallback = "Etc/UTC"
Fallback is the zone every detection failure lands on.
Variables ¶
This section is empty.
Functions ¶
func Ambiguous ¶
Ambiguous reports a wall time that names TWO instants — the hour a fall-back transition repeats. It is the question `fold` answers, and the only way a caller can know that answering it matters.
func Detect ¶
Detect resolves the host's zone: the TZ variable, then the /etc/localtime symlink, then the UTC fallback. The third return value is the "we fell back" warning flag Config carries.
func EarliestOn ¶
EarliestOn is the first instant of a calendar date in a zone. It scans forward a minute at a time because midnight itself can be skipped: some zones have moved their clock forward at 00:00 local.
func FirstValidLocalAfter ¶
func FirstValidLocalAfter(year int, month time.Month, day, hour, minute int, location *time.Location) (string, bool)
FirstValidLocalAfter is the hint a nonexistent-time diagnostic carries: the next wall time on the same date that the zone does observe.
func Get ¶
Get validates an identifier and returns its canonical spelling. The gate is deliberately narrow: anything without a "/" is refused unless it is exactly "UTC", so a POSIX TZ string cannot masquerade as a zone.
func InstantsFor ¶
func InstantsFor(year int, month time.Month, day, hour, minute int, location *time.Location) []time.Time
InstantsFor is TZInfo's periods_for_local, expressed as the UTC instants a wall time maps to: none across a spring-forward gap, one ordinarily, two across a fall-back overlap.
Go's time.Date cannot answer this — it silently picks one instant for an ambiguous wall time and an unspecified one for a nonexistent one — so the candidate offsets are probed either side of the transition and each is kept only when it round-trips back to the wall time that was asked for.
func Load ¶
Load resolves an identifier to a location. It goes through Get first, so the narrow IANA gate applies here too and a POSIX TZ string cannot slip past.
func TZDBVersion ¶
func TZDBVersion() string
TZDBVersion is the advisory self-report of where zone data came from. Ruby answers with TZInfo's data source; Go's is the zoneinfo directory the runtime found, or its embedded copy.
Types ¶
type Error ¶
type Error struct{ Message string }
Error is the one failure this package raises, matching Tasks::Timezones::Error.
type NonexistentLocalTime ¶
type NonexistentLocalTime struct{ Message string }
NonexistentLocalTime is Tasks::Timezones::NonexistentLocalTime: a wall time the zone skips over, such as 02:30 on a spring-forward morning.
func (*NonexistentLocalTime) Error ¶
func (e *NonexistentLocalTime) Error() string