type Location … type zone … type zoneTrans … const alpha … const omega … var UTC … var utcLoc … var Local … var localLoc … var localOnce … func (l *Location) get() *Location { … } // String returns a descriptive name for the time zone information, // corresponding to the name argument to [LoadLocation] or [FixedZone]. func (l *Location) String() string { … } var unnamedFixedZones … var unnamedFixedZonesOnce … // FixedZone returns a [Location] that always uses // the given zone name and offset (seconds east of UTC). func FixedZone(name string, offset int) *Location { … } func fixedZone(name string, offset int) *Location { … } // lookup returns information about the time zone in use at an // instant in time expressed as seconds since January 1, 1970 00:00:00 UTC. // // The returned information gives the name of the zone (such as "CET"), // the start and end times bracketing sec when that zone is in effect, // the offset in seconds east of UTC (such as -5*60*60), and whether // the daylight savings is being observed at that time. func (l *Location) lookup(sec int64) (name string, offset int, start, end int64, isDST bool) { … } // lookupFirstZone returns the index of the time zone to use for times // before the first transition time, or when there are no transition // times. // // The reference implementation in localtime.c from // https://www.iana.org/time-zones/repository/releases/tzcode2013g.tar.gz // implements the following algorithm for these cases: // 1. If the first zone is unused by the transitions, use it. // 2. Otherwise, if there are transition times, and the first // transition is to a zone in daylight time, find the first // non-daylight-time zone before and closest to the first transition // zone. // 3. Otherwise, use the first zone that is not daylight time, if // there is one. // 4. Otherwise, use the first zone. func (l *Location) lookupFirstZone() int { … } // firstZoneUsed reports whether the first zone is used by some // transition. func (l *Location) firstZoneUsed() bool { … } // tzset takes a timezone string like the one found in the TZ environment // variable, the time of the last time zone transition expressed as seconds // since January 1, 1970 00:00:00 UTC, and a time expressed the same way. // We call this a tzset string since in C the function tzset reads TZ. // The return values are as for lookup, plus ok which reports whether the // parse succeeded. func tzset(s string, lastTxSec, sec int64) (name string, offset int, start, end int64, isDST, ok bool) { … } // tzsetName returns the timezone name at the start of the tzset string s, // and the remainder of s, and reports whether the parsing is OK. func tzsetName(s string) (string, string, bool) { … } // tzsetOffset returns the timezone offset at the start of the tzset string s, // and the remainder of s, and reports whether the parsing is OK. // The timezone offset is returned as a number of seconds. func tzsetOffset(s string) (offset int, rest string, ok bool) { … } type ruleKind … const ruleJulian … const ruleDOY … const ruleMonthWeekDay … type rule … // tzsetRule parses a rule from a tzset string. // It returns the rule, and the remainder of the string, and reports success. func tzsetRule(s string) (rule, string, bool) { … } // tzsetNum parses a number from a tzset string. // It returns the number, and the remainder of the string, and reports success. // The number must be between min and max. func tzsetNum(s string, min, max int) (num int, rest string, ok bool) { … } // tzruleTime takes a year, a rule, and a timezone offset, // and returns the number of seconds since the start of the year // that the rule takes effect. func tzruleTime(year int, r rule, off int) int { … } // lookupName returns information about the time zone with // the given name (such as "EST") at the given pseudo-Unix time // (what the given time of day would be in UTC). func (l *Location) lookupName(name string, unix int64) (offset int, ok bool) { … } var errLocation … var zoneinfo … var zoneinfoOnce … // LoadLocation returns the Location with the given name. // // If the name is "" or "UTC", LoadLocation returns UTC. // If the name is "Local", LoadLocation returns Local. // // Otherwise, the name is taken to be a location name corresponding to a file // in the IANA Time Zone database, such as "America/New_York". // // LoadLocation looks for the IANA Time Zone database in the following // locations in order: // // - the directory or uncompressed zip file named by the ZONEINFO environment variable // - on a Unix system, the system standard installation location // - $GOROOT/lib/time/zoneinfo.zip // - the time/tzdata package, if it was imported func LoadLocation(name string) (*Location, error) { … } // containsDotDot reports whether s contains "..". func containsDotDot(s string) bool { … }