TZInfo
(require tzinfo) | package: tzinfo |
1 Introduction
The tzinfo library provides an interface for querying the IANA time zone database (also known as the Olson database).
UNIX systems usually come with a compiled version of the IANA database (typically in /usr/share/zoneinfo). tzinfo will use the system’s database if available. However, if the tzdata package is installed, that will be used instead. Since Windows systems do not come with a zoneinfo database, Windows users must install tzdata to use tzinfo.
2 Querying the Database
procedure
(tzid-exists? tzid) → boolean?
tzid : string?
Examples: | ||||
|
procedure
(utc-seconds->tzoffset tzid seconds) → tzoffset?
tzid : string? seconds : real?
Examples: | ||||
|
procedure
(local-seconds->tzoffset tzid seconds)
→ (or/c tzoffset? tzgap? tzoverlap?) tzid : string? seconds : real?
a tzoffset struct, describing the offset from UTC in effect at the given time in the given time zone;
a tzgap struct if the given local time falls into a gap between different offsets (as, for example, when an hour is skipped at the start of daylight saving time in most parts of the United States); or
a tzoverlap struct if the given local time falls in a period when two different offsets might be in effect (as, for example, at the end of daylight saving time, when an hour is repeated).
Raises exn:fail:tzinfo:zone-not-found if the given time zone ID is not in the database.
Examples: | ||||||
|
procedure
(tzid->country-codes tzid) → (listof string?)
tzid : string?
Examples: | ||||||
|
procedure
(country-code->tzids cc) → (listof string?)
cc : string?
Examples: | |||||||||||||||||||||||||||||||||
|
procedure
(system-tzid) → (or/c string? #f)
struct
3 Offsets, Gaps, and Overlaps
struct
(struct tzoffset (utc-seconds dst? abbreviation) #:transparent) utc-seconds : exact-integer? dst? : boolean? abbreviation : string?
struct
(struct tzgap (starts-at offset-before offset-after) #:transparent) starts-at : exact-integer? offset-before : tzoffset? offset-after : tzoffset?
struct
(struct tzoverlap (offset-before offset-after) #:transparent) offset-before : tzoffset? offset-after : tzoffset?
4 Data Sources
tzinfo allows for a pluggable data sources. At present, the only supported source is based on zoneinfo files, which are a compiled form of the IANA database, widely- used on UNIX systems.
parameter
(current-tzinfo-source) → tzinfo-source?
(current-tzinfo-source tzinfo-source) → void? tzinfo-source : tzinfo-source?
= #f
procedure
ctor : (-> tzinfo-source?)
5 Data Source Generics
(require tzinfo/source) | package: tzinfo |
value
gen:tzinfo-source : any/c
tzinfo->all-tzids
tzinfo-has-tzid?
tzinfo-tzid->country-codes
tzinfo-country-code->tzids
seconds->tzoffset/utc
seconds->tzoffset/local
detect-system-tzid
procedure
src : tzinfo-source? tzid : string?
procedure
(seconds->tzoffset/utc src tzid seconds) → tzoffset?
src : tzinfo-source? tzid : string? seconds : real?