UNPKG

datezone

Version:

A lightweight and comprehensive date and timeZone utility library for JavaScript.

61 lines 2.32 kB
import { type TimeZone } from "./timezone.pub.js"; /** * Represents a wall clock time with individual date and time components. * This type is used for representing time as it appears on a wall clock * in a specific timeZone, without any timeZone offset information. * * @example * ```typescript * const calendar: Calendar = { * year: 2024, * month: 1, // January (1-based) * day: 15, // 15th day of the month * hour: 14, // 2 PM (24-hour format) * minute: 30, // 30 minutes * second: 45, // 45 seconds * millisecond: 123 // 123 milliseconds * }; * ``` */ export type Calendar = { /** The year (4-digit, e.g., 2024) */ year: number; /** The month (1-based, where 1 = January, 12 = December) */ month: number; /** The day of the month (1-31) */ day: number; /** The hour in 24-hour format (0-23) */ hour: number; /** The minute (0-59) */ minute: number; /** The second (0-59) */ second: number; /** The millisecond (0-999) */ millisecond: number; }; /** * Calendar to timestamp. * * @param year - The year (4-digit) * @param month - The month (1-based, where 1 = January, 12 = December) * @param day - The day of the month (1-31) * @param hour - The hour (0-23) * @param minute - The minute (0-59) * @param second - The second (0-59) * @param millisecond - The milliseconds (0-999) * @param timeZone - The IANA timeZone identifier (e.g., 'America/New_York'). * @returns The UTC timestamp in milliseconds * @see https://datezone.dev/docs/reference/calendar#calendartotimestamp */ export declare function calendarToTimestamp(calendar: Partial<Calendar>, timeZone: TimeZone | null): number; export declare function calendarToTimestamp(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, timeZone: TimeZone | null): number; /** * Timestamp to calendar. * * @param ts - The timestamp in UTC milliseconds * @param tz - The IANA timeZone identifier (e.g., 'America/New_York'). * @returns The calendar in the specified timeZone * @see https://datezone.dev/docs/reference/calendar#timestamptocalendar */ export declare function timestampToCalendar(ts: number, tz: TimeZone | null): Calendar; //# sourceMappingURL=calendar.pub.d.ts.map