Import the plugin to hold a recurring date without inventing a placeholder year. Loading it adds .monthDay and as('monthDay') to calendar dates and zoned datetimes, and lets next() accept a month-day.
month-day.js
import { today } from 'native-dates';import { dayMonth, monthDay } from '@native-dates/plugins/month-day';const birthday = monthDay('10/17');const sameDay = dayMonth('17/10');birthday.equals(sameDay); // truebirthday.in(2027).toString(); // '2027-10-17'birthday.next(); // upcoming CalendarDate from todaytoday().next(birthday); // same upcoming occurrence
Reads month-first strings, two whole numbers, a fields object, or any date or timestamp with its year dropped. With the loose plugin, it also reads English month names and returns null when unreadable.
Parameters
inputMonthDayInput | numberrequired
Month-day string, fields object, existing date or timestamp, or 1-indexed month.
optionsZone | MonthDayOptions | number
Day of the month when passing two numbers, or a time zone or options object.
3 options
zoneZone
Time zone used to determine the calendar day of an instant string, DateTime, or Date.
dayFirstbooleandefault false
Read human-written strings like '17/10' day-first, matching dayMonth().
loosebooleandefault false
Read named months like 'Oct 17' and return null instead of throwing when unreadable.
Returns
MonthDay
An immutable MonthDay, or null when loose mode cannot read input.
Reads human-written strings and two-number pairs day-first into the same MonthDay class, regardless of global loose settings. Zero-padded ISO strings with two digits on each side of a dash always read month-first under both functions so JSON output round-trips cleanly.
Parameters
inputMonthDayInput | numberrequired
Day-first string such as '17/10', day of the month, or any MonthDayInput.
optionsZone | MonthDayOptions | number
1-indexed month when passing two numbers, or a zone or options object.
Returns
MonthDay
An immutable MonthDay, or null when loose mode cannot read input.
Finds the upcoming or most recent occurrence around a reference day, defaulting to today. If the reference day is already that occurrence, it steps a full year ahead or back. Passing a MonthDay to a date or datetime steps the same way while preserving clock time and zone.
Use equals() to check for the exact same month and day. Use fallsOn() for annual occurrences, where February 29 lands on February 28 in common years.
fallsOn()
md.fallsOn(day): boolean
Returns true when the given day is this month-day’s occurrence in that date’s own year, placing February 29 on February 28 in years without a leap day.
Parameters
dayCalendarDateInputrequired
Calendar date or timestamp to test.
Returns
boolean
true when this month-day lands on day in that year.
Returns true when the other input carries the same month and day. Accepts another month-day, an ISO month-day string, a fields object, or a date whose year is dropped. Ambiguous slash or dot strings throw so you read them with a month-first or day-first factory first.
Parameters
otherMonthDayInputrequired
MonthDay, ISO 'MM-DD' string, fields object, or date.
Returns
boolean
true when both values name the same month and day.
Formats the month and day in the order locale writes them, ignoring year, weekday, clock, and zone options. Accepts any preset name, an options object, custom entries in MonthDay.presets, or token patterns when the tokens plugin is loaded.
Parameters
specFormatSpecdefault 'medium'
Preset name such as 'short' or 'long', Intl.DateTimeFormatOptions, or token pattern.
localestring
BCP 47 locale tag overriding the configured default for this call.