UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

119 lines • 5.58 kB
export declare const TZ_VAR = "TZ"; /** A wall-clock reading: the calendar fields a zone shows for an instant. */ export interface WallParts { year: number; month: number; day: number; hour: number; minute: number; second: number; ms: number; } /** A wall-clock reading with the zone's offset and abbreviation at that instant. */ export interface ZoneParts extends WallParts { weekday: number; offsetSec: number; abbrev: string; } /** * A time zone: the wall clock it shows for an instant, and the instant its * wall clock reads as. `Date` has no zone of its own, so every rendering * (`strftime`) and every reading (`parseDateExpr`) goes through one of * these rather than through a `utc` flag. */ export interface Zone { parts(dt: Date): ZoneParts; /** * The instant whose wall clock reads `p`. A wall clock two instants share * (the hour repeated when DST ends) resolves to the one under `prefer`, * the offset in seconds east that a displaced moment started from, so a * moved time keeps the side of the change its base was on, and to the * later one without it, as GNU date resolves an absolute reading. One no * instant shows (the hour skipped when DST starts) is read under the * offset in force before the change and so lands forward by the gap, * which a caller that must refuse it detects by comparing `parts` of the * result against `p`. */ fromWall(p: WallParts, prefer?: number): Date; } /** * A Date from wall-clock fields read as UTC. `Date.UTC` reads a year below * 100 as 1900 plus that year; the setters do not, so a year GNU and Python * accept as itself (`0042-01-01`) lands where it belongs. Overflowing * fields carry, so day 32 is the next month's first. */ export declare function utcFromWall(p: WallParts): Date; /** * The abbreviation tzdata gives an offset it has no letters for: `+08`, * `-03`, `+0530`, with minutes only when they are not zero. */ export declare function numericAbbreviation(offsetSec: number): string; /** * The abbreviation tzdata gives `name` at `offsetSec` as of `atSec` (epoch * seconds), which is what GNU date prints for `%Z` and what Python's * zoneinfo renders. Intl only offers `GMT+8`, so the names ship in * TZ_ABBREVS (generated from zoneinfo by scripts/gen_tz_abbrevs.py), one * row per name an offset has carried with the moment it took effect: the * latest row for the offset that had taken effect by `atSec` wins, the * earliest stands in before the table's 1970 start, and an offset with no * row is one tzdata spells out (`+08`). */ export declare function tzAbbreviation(name: string, offsetSec: number, atSec: number): string; /** * One POSIX DST transition, `Mm.w.d`, `Jn` or `n`, with the local time of * day it happens at: `M` is month/week/weekday (week 5 is the last such * weekday, weekday 0 is Sunday), `J` a Julian day that never counts * February 29, `D` a zero-based day of the year that does. The time may * run past a day in either direction (`/-1`, `/25`), as POSIX allows. A * rule GNU date refused keeps the fields read of it (see weekdayRule), * which may sit outside POSIX's ranges; transitionAt places those where GNU * date 9.7 was measured to put them: week 0 counts as 1, a weekday past 6 * counts on from the Sunday that opens the month's first week, and `J` day * 0 is the day before January 1. */ export interface TransitionRule { kind: 'M' | 'J' | 'D'; month: number; week: number; weekday: number; day: number; seconds: number; } export declare function daysInMonth(year: number, month: number): number; /** The transition's wall-clock moment in `year`, as ms of that wall clock read as UTC. */ export declare function transitionAt(rule: TransitionRule, year: number): number; /** * When a POSIX TZ zone's daylight saving time starts and ends in a UTC year * (see PosixZone.transitions), null for any other zone, whose transitions come * from tzdata. Mirrors Python's posix_transitions. */ export declare function posixTransitions(zone: Zone, year: number): [number, number] | null; export declare const UTC_ZONE: Zone; export declare const LOCAL_ZONE: Zone; /** * The zone a command environment's TZ names, or null when TZ is unset (or * there is no environment), which means the host's local zone. */ export declare function zoneFromEnv(env: Readonly<Record<string, string>> | null | undefined): Zone | null; /** * The zone a TZ value names, read as GNU date 9.7 reads it: a leading * colon is dropped; an empty value is UTC; a name tzdata knows * (`Asia/Hong_Kong`, `UTC`, `EST5EDT`) is that zone; anything else is a * POSIX TZ string (`UTC0`, `JST-9`, `<+0530>-5:30`, * `CET-1CEST,M3.5.0,M10.5.0/3`), where a bare name with no offset is UTC * under that name, which is how GNU date renders `TZ=Bogus/Zone` * (`+0000 Bogus`), and a name shorter than three letters is refused, * leaving `%Z` empty. */ export declare function resolveTz(spec: string): Zone; /** * The zone a POSIX TZ string describes, as GNU 9.7 renders it: * `std offset [dst [offset] [,start[/time],end[/time]]]`. No DST name gives * a fixed zone, and a DST offset defaults to an hour east of the standard * one. A string GNU cannot read keeps what it read: no standard name is UTC * with an empty name (`AB5`), no standard offset UTC under the name (`XYZ`, * `Bogus/Zone`), and a DST name it cannot read a nameless half at UTC * (`EST5x`). */ export declare function posixZone(spec: string): Zone; //# sourceMappingURL=timezone.d.ts.map