Returns a string tag naming which type a value belongs to, or undefined for plain JavaScript values such as native dates, strings, numbers, and objects. Identifies moments, dates, times, durations, year-month and month-day values, and ranges.
Returns true when the value is a Time instance, narrowing its type in TypeScript.
import { isTime, time } from 'native-dates';isTime(time('9:30am')); // true
isDuration()
isDuration(value): value is Duration
Returns true when the value is a Duration instance, narrowing its type in TypeScript.
import { hours, isDuration } from 'native-dates';isDuration(hours(2)); // true
isYearMonth()
isYearMonth(value): value is YearMonth
Returns true when the value is a YearMonth instance, narrowing its type in TypeScript.
import { isYearMonth, yearMonth } from 'native-dates';isYearMonth(yearMonth('2026-11')); // true
isMonthDay()
isMonthDay(value): value is MonthDay
Returns true when the value is a MonthDay instance, narrowing its type in TypeScript.
import { isMonthDay, monthDay } from 'native-dates';isMonthDay(monthDay('10-17')); // true
isDateRange()
isDateRange(value): value is DateRange
Returns true when the value is a DateRange instance, narrowing its type in TypeScript.
import { dateRange, isDateRange } from 'native-dates';isDateRange(dateRange('2026-11-01', '2026-11-07')); // true
isDateTimeRange()
isDateTimeRange(value): value is DateTimeRange
Returns true when the value is a DateTimeRange instance, narrowing its type in TypeScript.
import { datetimeRange, isDateTimeRange } from 'native-dates';isDateTimeRange(datetimeRange('2026-11-16T09:00Z', '2026-11-16T10:00Z')); // true
isTimeRange()
isTimeRange(value): value is TimeRange
Returns true when the value is a TimeRange instance, narrowing its type in TypeScript.
import { isTimeRange, timeRange } from 'native-dates';isTimeRange(timeRange('9:00am', '5:00pm')); // true
Cross-realm instanceof and brands
Standard JavaScript instanceof checks fail across iframe boundaries and duplicate bundled copies. Every class here implements [Symbol.hasInstance] over a global registry symbol, so both instanceof and the guard functions work across realms.
You can also read the exported brand symbols directly when writing custom serializers, test matchers, or generic helpers that match any range kind through IS_RANGE: