UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

28 lines • 1.9 kB
import { Temporal } from "./temporal.js"; /** * Render a calendar phrase for a moment `diffDays` calendar days from the reference: "tomorrow at * 2:30 PM" within six days, else the long date and time. Shared by the zoned, utc and unix * calendar formatters. * * @param diffDays signed calendar-day distance from the reference, in `timeZone` * @param epochMilliseconds the moment to render * @param timeZone IANA zone the clock time is rendered in * @param locale BCP 47 locale(s) passed through to `Intl` * @param timeStyle the `Intl.DateTimeFormat` time style * @returns the phrase; throws where `Intl` throws, for the caller's sentinel * @example formatCalendarDays(1, 1710685800000, "UTC", "en-GB", "short") // "tomorrow at 14:30" * @example formatCalendarDays(-9, 1710685800000, "UTC", "en-GB", "short") // "17 March 2024 at 14:30" */ export declare function formatCalendarDays(diffDays: number, epochMilliseconds: number, timeZone: string, locale: string | string[] | undefined, timeStyle: "short" | "medium" | "long" | "full"): string; /** * `formatCalendarDays` for two instants, counting calendar days between their dates in `timeZone`. * * @param target the moment to render * @param reference the moment "today" is read from * @param timeZone IANA zone both dates and the clock time are read in * @param locale BCP 47 locale(s) passed through to `Intl` * @param timeStyle the `Intl.DateTimeFormat` time style * @returns the phrase; throws where Temporal or `Intl` throws * @example formatCalendarInstants(Temporal.Instant.from("2024-03-17T14:30:00Z"), Temporal.Instant.from("2024-03-16T09:00:00Z"), "UTC", "en-GB", "short") // "tomorrow at 14:30" */ export declare function formatCalendarInstants(target: Temporal.Instant, reference: Temporal.Instant, timeZone: string, locale: string | string[] | undefined, timeStyle: "short" | "medium" | "long" | "full"): string;