ts-time-utils
Version:
A comprehensive TypeScript utility library for time, dates, durations, and calendar operations with full tree-shaking support
34 lines • 1.69 kB
TypeScript
/**
* Timezone utilities using Intl API with fallbacks
*/
import type { ZonedTime } from './types.js';
/** Get offset (minutes) for a zone at a given date */
export declare function getTimezoneOffset(zone: string, date?: Date): number | null;
/** Format date/time in a zone */
export declare function formatInTimeZone(date: Date, zone: string, options?: Intl.DateTimeFormatOptions): string;
/** Get a lightweight ZonedTime object */
export declare function getZonedTime(date: Date, zone: string): ZonedTime | null;
/** Convert a date (treated as absolute moment) to another zone's clock components */
export declare function convertDateToZone(date: Date, zone: string): {
year: number;
month: number;
day: number;
hour: number;
minute: number;
second: number;
} | null;
/** Check if provided zone string is a valid IANA zone */
export declare function isValidTimeZone(zone: string): boolean;
/** List a subset of common timezones (cannot enumerate all via API) */
export declare const COMMON_TIMEZONES: string[];
/** Get current local offset in minutes */
export declare function getLocalOffset(): number;
/** Compare two timezones offset at given date */
export declare function compareZoneOffsets(zoneA: string, zoneB: string, date?: Date): number | null;
/** Shift a date by target zone offset difference relative to current local zone.
* This does not change the absolute moment; instead returns a new Date representing
* the same wall clock time in the target zone interpreted as local.
* For example useful for naive scheduling.
*/
export declare function reinterpretAsZone(date: Date, targetZone: string): Date | null;
//# sourceMappingURL=timezone.d.ts.map