@tubular/time
Version:
Date/time, IANA timezones, leap seconds, TAI/UTC conversions, calendar with settable Julian/Gregorian switchover
152 lines • 5.16 kB
TypeScript
import { YMDDate } from './common';
export interface OffsetsAndZones {
offset: string;
offsetSeconds: number;
dstOffset: number;
zones: string[];
}
export interface RegionAndSubzones {
region: string;
subzones: string[];
}
export interface Transition {
transitionTime: number;
utcOffset: number;
dstOffset: number;
name?: string;
deltaOffset?: number;
dstFlipped?: boolean;
baseOffsetChanged?: boolean;
wallTime?: number;
wallTimeDay?: number;
}
export interface ZoneInfo {
zoneName: string;
currentUtcOffset: number;
usesDst: boolean;
dstOffset: number;
displayName?: string;
transitions: Transition[] | null;
population?: number;
countries?: Set<string>;
aliasFor?: string;
stdRule?: Rule;
dstRule?: Rule;
}
export interface ShortZoneNameInfo {
utcOffset: number;
dstOffset: number;
ianaName: string;
}
declare class Rule {
startYear: number;
month: number;
dayOfMonth: number;
dayOfWeek: number;
atHour: number;
atMinute: number;
atType: number;
save: number;
constructor(ruleStr: string);
getTransitionTime(year: number, stdOffset: number, dstOffset: number): number;
toString(): string;
}
export interface LeapSecondInfo {
utcMillis: number;
taiMillis: number;
dateAfter: YMDDate;
deltaTai: number;
isNegative: boolean;
inLeap?: boolean;
inNegativeLeap?: boolean;
}
export declare class Timezone {
private static encodedTimezones;
private static shortZoneNames;
private static zonesByLowercase;
private static zonesByOffsetAndDst;
private static countriesForZone;
private static zonesForCountry;
private static populationForZone;
private static leapSeconds;
private static lastLeapSecond;
private static _version;
static get version(): string;
static OS_ZONE: Timezone;
static UT_ZONE: Timezone;
static TAI_ZONE: Timezone;
static ZONELESS: Timezone;
static DATELESS: Timezone;
private static offsetsAndZones;
private static regionAndSubzones;
private static zoneLookup;
private static zonesAliases;
private readonly _zoneName;
private readonly _utcOffset;
private readonly _usesDst;
private readonly _dstOffset;
private readonly displayName;
private readonly transitions;
private readonly _aliasFor;
private readonly _countries;
private readonly _population;
private readonly _stdRule;
private readonly _dstRule;
private _error;
static defineTimezones(encodedTimezones: Record<string, string>): boolean;
static getAvailableTimezones(): string[];
static getOffsetsAndZones(): OffsetsAndZones[];
static getRegionsAndSubzones(): RegionAndSubzones[];
private static _guess;
static guess(recheck?: boolean, testCountry?: string, testZone?: string): string;
static has(name: string): boolean;
static from(name: string): Timezone;
static getTimezone(name?: string, longitude?: number): Timezone;
static getAliasesForZone(zone: string): string[];
static hasShortName(name: string): boolean;
static getShortZoneNameInfo(shortName: string): ShortZoneNameInfo;
static getPopulation(zoneName: string): number;
static getCountries(zoneName: string): Set<string>;
static doesZoneMatchCountry(zoneName: string, country: string): boolean;
private static parseTimeOffset;
private static fromBase60;
private static extractTimezoneTransitionsFromIntl;
private static applyTransitionRules;
private static countriesStringToSet;
private static parseEncodedTimezone;
private static buildAliases;
private static extractZoneInfo;
private static extractDeltaTs;
private static extractLeapSeconds;
static formatUtcOffset(offsetSeconds: number, noColons?: boolean): string;
static getDstSymbol(dstOffsetSeconds: number): string;
constructor(zoneInfo: ZoneInfo);
get zoneName(): string;
get utcOffset(): number;
get usesDst(): boolean;
get dstOffset(): number;
get error(): string | undefined;
get aliasFor(): string | undefined;
get countries(): Set<string>;
get population(): number;
get stdRule(): string;
get dstRule(): string;
getOffset(utcTime: number, day?: number): number;
getDisplayName(utcTime: number): string;
supportsCountry(country: string): boolean;
getOffsetForWallTime(wallTime: number): number;
getFormattedOffset(utcTime: number, noColons?: boolean): string;
getOffsets(utcTime: number): number[];
isDuringDst(utcTime: number): boolean;
getAllTransitions(): Transition[] | null;
findTransitionByUtc(utcTime: number): Transition | null;
static findDeltaTaiFromUtc(utcTime: number): LeapSecondInfo;
static getLeapSecondList(): LeapSecondInfo[];
static getDateAfterLastKnownLeapSecond(): YMDDate;
static getUpcomingLeapSecond(): YMDDate;
static findDeltaTaiFromTai(taiTime: number): LeapSecondInfo;
findTransitionByWallTime(wallTime: number): Transition | null;
private matchRating;
}
export {};
//# sourceMappingURL=timezone.d.ts.map