Skip to content

monthDayToDate

monthDayToDate(monthDay: string, year: number): string

The ISO date of a month-day in a given year.

  • --02-29 in a year that is not a leap year gives 28 February. This is the constrain step of Temporal’s PlainMonthDay.prototype.toPlainDate (CalendarDateFromFields with constrain). The result is never 1 March and never "".
  • year must be an integer. A fractional, string or bigint year gives ""; Temporal would truncate or coerce it, and gmt does not.
  • Only the ISO calendar is read; a month-day with another calendar annotation gives "".
ParameterTypeDescription
monthDaystringa month-day, --MM-DD or MM-DD
yearnumberan integer, as Temporal’s ISO calendar counts it: 0 is 1 BCE and -1 is 2 BCE

the ISO date, or "" when monthDay is not a valid month-day, year is not an integer, or the date falls outside the PlainDate range

import { monthDayToDate } from "@northguild/gmt/plain/convert";
monthDayToDate("--12-25", 2024) // "2024-12-25"
output 

plain/convert/monthDayToDate.ts

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.