isRelativeDay
Signature
Section titled “Signature”isRelativeDay(value: string, offsetDays: number): booleanReturn true when value falls offsetDays days from today, per the system clock and system timeZone.
- Subsumes
isToday/isYesterday/isTomorrow:offsetDays: 0is “today”,-1is “yesterday”,1is “tomorrow”, and any other integer offset works the same way. - Compares against today, so this depends on the system clock and system timeZone. The same call returns different answers on hosts in different timeZones at the same instant — a caller needing determinism (server-side rendering, tests, scheduled jobs) should use
isZonedRelativeDaywith an explicit timeZone, or compare against an explicit reference withareDatesEqualBy. offsetDaysmust be an integer; non-integer or non-finite values return false.- Returns false if
valueis invalid or the system timeZone is unavailable. Migrating from date-fns: isToday(value)→isRelativeDay(value, 0)isYesterday(value)→isRelativeDay(value, -1)isTomorrow(value)→isRelativeDay(value, 1)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO PlainDate string |
offsetDays | number | integer number of days from today (0 = today, -1 = yesterday, 1 = tomorrow) |
Returns
Section titled “Returns”true if value is exactly offsetDays days from today, false on invalid input
Examples
Section titled “Examples”import { isRelativeDay } from "@northguild/gmt/plain/compare";
isRelativeDay("2024-03-15", 0) // true, if today is 2024-03-15Source
Section titled “Source”Accessibility
© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.