Returns the next occurrence strictly after a reference date, defaulting to today(). When the reference date already falls on this month and day, the method advances to the following year.
Calendar dates and moments also accept a month-day directly in d.next(md) and dt.next(md).
Returns the most recent occurrence strictly before a reference date, defaulting to today(). Calendar dates and moments also accept a month-day directly in previous().
Because a month-day repeats every year rather than sitting at one point on a timeline, ordering methods like isBefore() do not apply.
Choosing equals or fallsOn
Use fallsOn() to check whether a calendar date is that year’s observance, since February 29 lands on February 28 in common years. Reserve equals() for checking whether two values write the exact same month and day numbers.
fallsOn()
md.fallsOn(day): boolean
Returns true when the given date is this month-day’s occurrence in that date’s own year. In a common year, February 29 falls on February 28, whereas in a leap year it falls only on February 29.
Parameters
dayCalendarDateInputrequired
Date string, CalendarDate, DateTime, fields object, or Date.
Returns
boolean
true when day is this month-day's date in that year.
Returns true when this month-day falls on today’s date in the given or configured time zone.
import { today } from 'native-dates';today('UTC').monthDay.isToday('UTC'); // true
isTomorrow()
md.isTomorrow(zone?): boolean
Returns true when this month-day falls on tomorrow’s date in the given or configured time zone.
import { tomorrow } from 'native-dates';tomorrow('UTC').monthDay.isTomorrow('UTC'); // true
isYesterday()
md.isYesterday(zone?): boolean
Returns true when this month-day falls on yesterday’s date in the given or configured time zone.
import { yesterday } from 'native-dates';yesterday('UTC').monthDay.isYesterday('UTC'); // true
Formatting and conversion
format()
md.format(spec?, locale?): string
Formats the month and day in the locale’s own order, or with a built-in token pattern such as 'MMM Do'. Shared options objects ignore year, clock, and zone keys automatically.
Custom named presets can be added on MonthDay.presets, and non-Gregorian locales format Gregorian month names so annual dates stay stable. See Formatting for all preset and token options.
Parameters
specFormatSpecdefault 'medium'
Preset name such as 'short' or 'long', Intl options object, or token pattern.
localeLocale
BCP 47 locale tag overriding the configured default for this call.
Returns this instance when 'monthDay' is requested in generic conversion chains, throwing a RangeError for other kinds.
toString()
md.toString(): stringmd.toJSON(): string
Returns the two-digit ISO month-day string 'MM-DD', which round-trips month-first under both month-day factories. toJSON() returns the same string for JSON serialization.