Returns the next occurrence 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 before a reference date, defaulting to today(). Calendar dates and moments also accept a month-day directly in previous(). It is also aliased as last().
Because a month-day repeats every year rather than representing a single date, 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 resolves to February 28 in common years. Reserve equals() for checking whether two values have the exact same month and day numbers.
fallsOn()
md.fallsOn(day): booleanmd.isOn(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. It is also aliased as isOn().
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 formats registered in configure() work here too, 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 this value's or the configured locale for one call.
Reads the locale carried on this month-day, or returns a copy formatted in another locale across text previews, presets, and every date derived from it. Passing an empty tag clears the carried locale, and lang() works as an alias.
Parameters
tagLocale | null | undefined
BCP 47 locale tag to carry forward, or null to clear an existing tag.
Returns
MonthDay | Locale | undefined
The active tag when called with no arguments, or a new MonthDay carrying tag.
Shorthand alias for locale() that reads or attaches a BCP 47 locale tag on this month-day.
as()
md.as('monthDay'): MonthDay
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.