Comparison helpers avoid repeatedly converting Timestamp objects back into native Date values.
Compare date and time separately
import { function compareDate(ts1: Timestamp, ts2: Timestamp): booleanCompares the calendar date portion of two Timestamp objects.compareDate, function compareDateTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted date and time portions of two Timestamp objects.compareDateTime, function compareTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted time portion of two Timestamp objects.compareTime, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const first: Timestampfirst = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08 09:30')!
const const second: Timestampsecond = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08 10:00')!
function compareDate(ts1: Timestamp, ts2: Timestamp): booleanCompares the calendar date portion of two Timestamp objects.compareDate(const first: Timestampfirst, const second: Timestampsecond) // true
function compareTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted time portion of two Timestamp objects.compareTime(const first: Timestampfirst, const second: Timestampsecond) // false
function compareDateTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted date and time portions of two Timestamp objects.compareDateTime(const first: Timestampfirst, const second: Timestampsecond) // falseComparison helpers return booleans. Use identifiers or min/max helpers when you need ordering.
import {
function getDayIdentifier(timestamp: Timestamp): numberConverts a Timestamp date into a sortable numeric identifier.getDayIdentifier,
function getDayTimeIdentifier(timestamp: Timestamp): numberConverts a Timestamp date and time into a sortable numeric identifier.getDayTimeIdentifier,
function getTimeIdentifier(timestamp: Timestamp): numberConverts a Timestamp time into a sortable numeric identifier.getTimeIdentifier,
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp,
} from '@timestamp-js/core'
const const first: Timestampfirst = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08 09:30')!
const const second: Timestampsecond = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08 10:00')!
function getDayIdentifier(timestamp: Timestamp): numberConverts a Timestamp date into a sortable numeric identifier.getDayIdentifier(const first: Timestampfirst) // 202606080000
function getTimeIdentifier(timestamp: Timestamp): numberConverts a Timestamp time into a sortable numeric identifier.getTimeIdentifier(const first: Timestampfirst) // 930
function getDayTimeIdentifier(timestamp: Timestamp): numberConverts a Timestamp date and time into a sortable numeric identifier.getDayTimeIdentifier(const first: Timestampfirst) < function getDayTimeIdentifier(timestamp: Timestamp): numberConverts a Timestamp date and time into a sortable numeric identifier.getDayTimeIdentifier(const second: Timestampsecond) // trueCompare exact timestamps
Use compareTimestamps() when timezone suffixes and sub-minute precision matter too.
import { function compareDateTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted date and time portions of two Timestamp objects.compareDateTime, function compareTimestamps(ts1: Timestamp, ts2: Timestamp): booleanCompares two Timestamp objects for exact date, time, and timezone equality.compareTimestamps, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const utc: Timestamputc = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-08T09:30:15.250Z')!
const const offset: Timestampoffset = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-08T09:30:15.250-07:00')!
function compareDateTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted date and time portions of two Timestamp objects.compareDateTime(const utc: Timestamputc, const offset: Timestampoffset) // true
function compareTimestamps(ts1: Timestamp, ts2: Timestamp): booleanCompares two Timestamp objects for exact date, time, and timezone equality.compareTimestamps(const utc: Timestamputc, const offset: Timestampoffset) // falseCheck inclusive date ranges
import { function isBetweenDates(timestamp: Timestamp, startTimestamp: Timestamp, endTimestamp: Timestamp, useTime?: boolean): booleanChecks whether a Timestamp falls inside an inclusive range.isBetweenDates, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const start: Timestampstart = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-01')!
const const end: Timestampend = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-30')!
const const target: Timestamptarget = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08')!
function isBetweenDates(timestamp: Timestamp, startTimestamp: Timestamp, endTimestamp: Timestamp, useTime?: boolean): booleanChecks whether a Timestamp falls inside an inclusive range.isBetweenDates(const target: Timestamptarget, const start: Timestampstart, const end: Timestampend) // trueCreate reusable range objects
Use TimestampRange when the same inclusive boundaries need to flow through several helpers.
import {
function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange,
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate,
function isTimestampInRange(timestamp: Timestamp, range: TimestampRange, useTime?: boolean): booleanChecks whether a Timestamp falls inside an inclusive TimestampRange.isTimestampInRange,
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp,
} from '@timestamp-js/core'
const const june: TimestampRangejune = function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-01')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-30')!)
const const target: Timestamptarget = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-08')!
function isTimestampInRange(timestamp: Timestamp, range: TimestampRange, useTime?: boolean): booleanChecks whether a Timestamp falls inside an inclusive TimestampRange.isTimestampInRange(const target: Timestamptarget, const june: TimestampRangejune) // true
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(const june: TimestampRangejune.TimestampRange.start: TimestampInclusive range start.start) // "2036-06-01"
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(const june: TimestampRangejune.TimestampRange.end: TimestampInclusive range end.end) // "2036-06-30"Check overlap between ranges
import { function isOverlappingDates(startTimestamp: Timestamp, endTimestamp: Timestamp, firstTimestamp: Timestamp, lastTimestamp: Timestamp): booleanChecks whether two inclusive Timestamp ranges overlap.isOverlappingDates, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const vacationStart: TimestampvacationStart = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-10')!
const const vacationEnd: TimestampvacationEnd = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-14')!
const const blackoutStart: TimestampblackoutStart = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-12')!
const const blackoutEnd: TimestampblackoutEnd = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-18')!
function isOverlappingDates(startTimestamp: Timestamp, endTimestamp: Timestamp, firstTimestamp: Timestamp, lastTimestamp: Timestamp): booleanChecks whether two inclusive Timestamp ranges overlap.isOverlappingDates(const vacationStart: TimestampvacationStart, const vacationEnd: TimestampvacationEnd, const blackoutStart: TimestampblackoutStart, const blackoutEnd: TimestampblackoutEnd) // trueCheck overlap between reusable range objects
Use isRangeOverlapping() when your app already passes around TimestampRange values.
import { function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange, function isRangeOverlapping(first: TimestampRange, second: TimestampRange, useTime?: boolean): booleanChecks whether two inclusive TimestampRange values overlap.isRangeOverlapping, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const planningWindow: TimestampRangeplanningWindow = function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-01')!,
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-30')!,
)
const const blackout: TimestampRangeblackout = function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-12')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-18')!)
function isRangeOverlapping(first: TimestampRange, second: TimestampRange, useTime?: boolean): booleanChecks whether two inclusive TimestampRange values overlap.isRangeOverlapping(const planningWindow: TimestampRangeplanningWindow, const blackout: TimestampRangeblackout) // trueIntersect two ranges
intersectRanges() returns the shared section of two ranges, or null when they do not overlap.
import { function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange, function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate, function intersectRanges(first: TimestampRange, second: TimestampRange, useTime?: boolean): TimestampRange | nullReturns the inclusive intersection of two TimestampRange values.intersectRanges, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const sprint: TimestampRangesprint = function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-01')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-20')!)
const const blackout: TimestampRangeblackout = function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-10')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-30')!)
const const overlap: TimestampRange | nulloverlap = function intersectRanges(first: TimestampRange, second: TimestampRange, useTime?: boolean): TimestampRange | nullReturns the inclusive intersection of two TimestampRange values.intersectRanges(const sprint: TimestampRangesprint, const blackout: TimestampRangeblackout)
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(const overlap: TimestampRange | nulloverlap!.TimestampRange.start: TimestampInclusive range start.start) // "2036-06-10"
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(const overlap: TimestampRange | nulloverlap!.TimestampRange.end: TimestampInclusive range end.end) // "2036-06-20"Merge touching ranges
mergeRanges() sorts the ranges and joins ranges that overlap or touch. Date-only ranges touch when the next range starts on the next calendar day.
import { function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange, function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate, function mergeRanges(ranges: TimestampRange[], useTime?: boolean): TimestampRange[]Merges overlapping or touching TimestampRange values.
Date-only ranges touch when the next range starts on the next calendar day.
Time-aware ranges touch when the next range starts one millisecond after the
previous range ends.mergeRanges, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const merged: TimestampRange[]merged = function mergeRanges(ranges: TimestampRange[], useTime?: boolean): TimestampRange[]Merges overlapping or touching TimestampRange values.
Date-only ranges touch when the next range starts on the next calendar day.
Time-aware ranges touch when the next range starts one millisecond after the
previous range ends.mergeRanges([
function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-10')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-12')!),
function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-01')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-04')!),
function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-05')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-07')!),
])
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(const merged: TimestampRange[]merged[0]!.TimestampRange.start: TimestampInclusive range start.start) // "2036-06-01"
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(const merged: TimestampRange[]merged[0]!.TimestampRange.end: TimestampInclusive range end.end) // "2036-06-07"
const merged: TimestampRange[]merged.Array<TimestampRange>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.length // 2Subtract blocked dates
subtractRanges() returns the pieces of a source range that remain after blocked ranges are removed.
import { function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange, function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp, function subtractRanges(source: TimestampRange, blocked: TimestampRange[], useTime?: boolean): TimestampRange[]Subtracts blocked ranges from a source range.
The result is useful for availability windows because it returns the pieces
of the source range that remain after each blocked range is removed.subtractRanges } from '@timestamp-js/core'
const const month: TimestampRangemonth = function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-01')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-30')!)
const const maintenance: TimestampRange[]maintenance = [
function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-10')!, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-12')!),
]
const const available: TimestampRange[]available = function subtractRanges(source: TimestampRange, blocked: TimestampRange[], useTime?: boolean): TimestampRange[]Subtracts blocked ranges from a source range.
The result is useful for availability windows because it returns the pieces
of the source range that remain after each blocked range is removed.subtractRanges(const month: TimestampRangemonth, const maintenance: TimestampRange[]maintenance)
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(const available: TimestampRange[]available[0]!.TimestampRange.end: TimestampInclusive range end.end) // "2036-06-09"
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(const available: TimestampRange[]available[1]!.TimestampRange.start: TimestampInclusive range start.start) // "2036-06-13"Find time-aware gaps
Pass true for useTime when ranges represent instants inside a day. Time-aware gaps use millisecond boundaries so adjacent ranges stay precise.
import { function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange, function findRangeGaps(source: TimestampRange, occupied: TimestampRange[], useTime?: boolean): TimestampRange[]Finds open gaps inside a source range after occupied ranges are removed.
This is an alias for subtractRanges() with naming that reads naturally in
booking, resource, and availability workflows.findRangeGaps, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const workBlock: TimestampRangeworkBlock = function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-08T09:00')!,
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-08T10:00')!,
true,
)
const const booked: TimestampRange[]booked = [
function createTimestampRange(start: Timestamp, end: Timestamp, useTime?: boolean): TimestampRangeCreates an inclusive Timestamp range and normalizes start/end order.createTimestampRange(
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-08T09:15')!,
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-08T09:29:59.999')!,
true,
),
]
const const gaps: TimestampRange[]gaps = function findRangeGaps(source: TimestampRange, occupied: TimestampRange[], useTime?: boolean): TimestampRange[]Finds open gaps inside a source range after occupied ranges are removed.
This is an alias for subtractRanges() with naming that reads naturally in
booking, resource, and availability workflows.findRangeGaps(const workBlock: TimestampRangeworkBlock, const booked: TimestampRange[]booked, true)
const gaps: TimestampRange[]gaps[0]!.TimestampRange.end: TimestampInclusive range end.end.Timestamp.time?: string | undefinedFormatted time string.
Minute precision is formatted as `HH:mm`; second precision as `HH:mm:ss`;
millisecond precision as `HH:mm:ss.SSS`.time // "09:14:59.999"
const gaps: TimestampRange[]gaps[1]!.TimestampRange.start: TimestampInclusive range start.start.Timestamp.time?: string | undefinedFormatted time string.
Minute precision is formatted as `HH:mm`; second precision as `HH:mm:ss`;
millisecond precision as `HH:mm:ss.SSS`.time // "09:30"Pick min and max values
import { function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate, function maxTimestamp(timestamps: Timestamp[], useTime?: boolean): TimestampFinds the latest Timestamp in an array.maxTimestamp, function minTimestamp(timestamps: Timestamp[], useTime?: boolean): TimestampFinds the earliest Timestamp in an array.minTimestamp, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const dates: Timestamp[]dates = [
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08')!,
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-12')!,
function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-01')!,
]
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(function minTimestamp(timestamps: Timestamp[], useTime?: boolean): TimestampFinds the earliest Timestamp in an array.minTimestamp(const dates: Timestamp[]dates)) // "2026-06-01"
function getDate(timestamp: Timestamp): stringFormats the date portion of a Timestamp object.getDate(function maxTimestamp(timestamps: Timestamp[], useTime?: boolean): TimestampFinds the latest Timestamp in an array.maxTimestamp(const dates: Timestamp[]dates)) // "2026-06-12"Measure differences
diffTimestamp() returns milliseconds. daysBetween() and weeksBetween() provide common calendar-sized measurements.
import { function daysBetween(ts1: Timestamp, ts2: Timestamp): numberReturns number of days between two TimestampsdaysBetween, function diffTimestamp(ts1: Timestamp, ts2: Timestamp, strict?: boolean): numberReturns the difference between two TimestampsdiffTimestamp, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp, function weeksBetween(ts1: Timestamp, ts2: Timestamp): numberReturns number of weeks between two TimestampsweeksBetween } from '@timestamp-js/core'
const const start: Timestampstart = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-01')!
const const end: Timestampend = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2036-06-15')!
function diffTimestamp(ts1: Timestamp, ts2: Timestamp, strict?: boolean): numberReturns the difference between two TimestampsdiffTimestamp(const start: Timestampstart, const end: Timestampend) // 1209600000
function daysBetween(ts1: Timestamp, ts2: Timestamp): numberReturns number of days between two TimestampsdaysBetween(const start: Timestampstart, const end: Timestampend) // 14
function weeksBetween(ts1: Timestamp, ts2: Timestamp): numberReturns number of weeks between two TimestampsweeksBetween(const start: Timestampstart, const end: Timestampend) // 3