datezone
Version:
A lightweight and comprehensive date and timeZone utility library for JavaScript.
43 lines • 1.93 kB
TypeScript
import type { Calendar } from "./calendar.pub.js";
import { type TimeZone } from "./timezone.pub.js";
/**
* Interval to duration.
*
* @param start The first timestamp (Unix epoch ms).
* @param end The second timestamp (Unix epoch ms).
* @param timeZone The IANA timeZone identifier or `null`/`undefined` to use
* @returns A partial {@link Calendar} where each defined field represents the
* @see https://datezone.dev/docs/reference/duration#intervaltoduration
*/
export declare function intervalToDuration(start: number, end: number, timeZone: TimeZone | null): Calendar;
/**
* Interval to duration base.
*
* @param startCal Calendar representation of the **earlier** instant.
* @param endCal Calendar representation of the **later** instant.
* @returns Calendar-like object containing the differences of each field.
* @see https://datezone.dev/docs/reference/duration#intervaltodurationbase
*/
export declare function intervalToDurationBase(startCal: Calendar, endCal: Calendar): Calendar;
/**
* Are intervals overlapping.
*
* @param start1 First interval start (inclusive).
* @param end1 First interval end (exclusive).
* @param start2 Second interval start (inclusive).
* @param end2 Second interval end (exclusive).
* @returns `true` if the intervals share at least one point.
* @see https://datezone.dev/docs/reference/duration#areintervalsoverlapping
*/
export declare function areIntervalsOverlapping(start1: number, end1: number, start2: number, end2: number): boolean;
/**
* Extracts the clamp from a timestamp.
*
* @param value The candidate value.
* @param min Lower bound.
* @param max Upper bound.
* @returns `min` if *value < min*, `max` if *value > max* otherwise the original value.
* @see https://datezone.dev/docs/reference/duration#clamp
*/
export declare function clamp(value: number, min: number, max: number): number;
//# sourceMappingURL=duration.pub.d.ts.map