timezone-codes
Version:
[DEPRECATED] A comprehensive, typed dataset of IANA timezone identifiers with metadata.
77 lines (74 loc) • 2.79 kB
text/typescript
/**
* Represents an IANA timezone name (e.g., 'America/New_York')
*/
type IANATimezoneName = string;
/**
* Represents a timezone abbreviation (e.g., 'EST', 'JST')
*/
type TimezoneAbbreviation = string;
/**
* Represents a UTC offset string (e.g., '-05:00', '+09:00')
*/
type UTCOffset = string;
/**
* Represents a timezone region (e.g., 'America', 'Asia', 'Europe')
*/
type TimezoneRegion = string;
/**
* Represents a complete timezone entry with metadata
*/
interface Timezone {
/** The IANA timezone name (e.g., 'America/New_York') */
name: IANATimezoneName;
/** The standard UTC offset (e.g., '-05:00') */
standardUtcOffset: UTCOffset;
/** The standard time abbreviation (e.g., 'EST') */
standardAbbreviation: TimezoneAbbreviation;
/** The region derived from the IANA name (e.g., 'America') */
region: TimezoneRegion;
}
/**
* Represents the current timezone details including DST information
*/
interface CurrentTimezoneDetails {
/** The current UTC offset including DST if applicable */
currentUtcOffset: UTCOffset;
/** The current timezone abbreviation including DST if applicable */
currentAbbreviation: TimezoneAbbreviation;
}
/**
* The complete list of timezones with their metadata.
* This is a readonly array to prevent accidental modifications.
*/
declare const timezones: Readonly<Timezone[]>;
/**
* Gets a timezone by its IANA name.
* @param name - The IANA timezone name to look up
* @returns The timezone object if found, undefined otherwise
*/
declare function getTimezoneByName(name: IANATimezoneName | string): Timezone | undefined;
/**
* Gets all timezones in a specific region.
* @param region - The region to filter by (case-insensitive)
* @returns Array of timezones in the specified region
*/
declare function getTimezonesByRegion(region: TimezoneRegion | string): Timezone[];
/**
* Gets the standard UTC offset for a timezone.
* @param name - The IANA timezone name
* @returns The standard UTC offset if found, undefined otherwise
*/
declare function getStandardUtcOffset(name: IANATimezoneName | string): UTCOffset | undefined;
/**
* Checks if a string is a valid IANA timezone name.
* @param name - The string to check
* @returns true if the string is a valid IANA timezone name
*/
declare function isValidTimezoneName(name: string): boolean;
/**
* Gets the current timezone details including DST information.
* @param name - The IANA timezone name
* @returns Promise resolving to current timezone details or undefined if not found
*/
declare function getCurrentTimezoneDetails(name: IANATimezoneName): Promise<CurrentTimezoneDetails | undefined>;
export { getCurrentTimezoneDetails, getStandardUtcOffset, getTimezoneByName, getTimezonesByRegion, isValidTimezoneName, timezones };