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.

69 lines • 3.57 kB
import { Temporal } from "./temporal.js"; import { IntervalNanoseconds } from "./intervalNanoseconds.js"; /** * The check behind `isValidDateInterval`. * * @param start the candidate start; a value that is not a string is not a date * @param end the candidate end * @returns both calendar dates, in the computation calendar, when `start` is not after `end`, else `null` * * @example dateIntervalOf("2024-01-01", "2024-01-31")?.[1].day // 31 * @example dateIntervalOf("2024-02-01", "2024-01-01") // null */ export declare function dateIntervalOf(start: unknown, end: unknown): readonly [Temporal.PlainDate, Temporal.PlainDate] | null; /** * The check behind `isValidDateTimeInterval`. * * @param start the candidate start; a value that is not a string is not a date-time * @param end the candidate end * @returns both date-times when `start` is not after `end`, else `null` * * @example dateTimeIntervalOf("2024-01-01T08:00", "2024-01-01T17:00")?.[0].hour // 8 * @example dateTimeIntervalOf("2024-01-01T17:00", "2024-01-01T08:00") // null */ export declare function dateTimeIntervalOf(start: unknown, end: unknown): readonly [Temporal.PlainDateTime, Temporal.PlainDateTime] | null; /** * The check behind `isValidTimeInterval`. * * @param start the candidate start; a value that is not a string is not a time * @param end the candidate end * @returns both times when `start` is not after `end`, else `null` * * @example timeIntervalOf("08:00", "17:00")?.[1].hour // 17 * @example timeIntervalOf("17:00", "08:00") // null */ export declare function timeIntervalOf(start: unknown, end: unknown): readonly [Temporal.PlainTime, Temporal.PlainTime] | null; /** * The check behind `isValidUtcInterval`. * * @param start the candidate start; a value that is not a string is not a UTC string * @param end the candidate end * @returns both instants when `start` is not after `end`, else `null` * * @example utcIntervalOf("2024-01-01T00:00:00Z", "2024-01-02T00:00:00Z")?.[1].epochMilliseconds // 1704153600000 * @example utcIntervalOf("2024-01-02T00:00:00Z", "2024-01-01T00:00:00Z") // null */ export declare function utcIntervalOf(start: unknown, end: unknown): readonly [Temporal.Instant, Temporal.Instant] | null; /** * A UTC interval read once into the record the interval cores take: epoch nanoseconds plus the * canonical text of each endpoint. * * @param start the candidate start; a value that is not a string is not a UTC string * @param end the candidate end * @returns the record when `start` is not after `end`, else `null` * * @example utcIntervalRecordOf("2024-01-01T00:00:00Z", "2024-01-01T00:00:01Z")?.end // 1704067201000000000n * @example utcIntervalRecordOf("2024-01-02T00:00:00Z", "2024-01-01T00:00:00Z") // null */ export declare function utcIntervalRecordOf(start: unknown, end: unknown): IntervalNanoseconds | null; /** * The check behind `isValidCalendarZonedInterval`. * * @param start the candidate start; a value that is not a string is not a zoned date-time * @param end the candidate end * @returns both zoned date-times, in the computation calendar, when the start instant is not after the end instant, else `null` * * @example calendarZonedIntervalOf("2024-03-10T08:00:00+00:00[UTC]", "2024-03-10T09:00:00+00:00[UTC]")?.[0].hour // 8 * @example calendarZonedIntervalOf("2024-03-10T09:00:00+00:00[UTC]", "2024-03-10T08:00:00+00:00[UTC]") // null */ export declare function calendarZonedIntervalOf(start: unknown, end: unknown): readonly [Temporal.ZonedDateTime, Temporal.ZonedDateTime] | null;