Skip to content

compareMonthDays

compareMonthDays(a: string, b: string): number | null

Compare two month-day strings (--MM-DD, or MM-DD) in calendar order: month first, then day.

  • Accepts both input forms, so 12-25 and --12-25 compare equal.
  • The year is not part of a month-day: --02-29 sorts between --02-28 and --03-01. (Temporal has no PlainMonthDay.compare; this compares the matching PlainDates in the leap reference year 1972, as the note on PlainMonthDay.prototype.valueOf directs.)
  • Returns null if either input is invalid or not in the ISO calendar.
ParameterTypeDescription
astringmonth-day string
bstringmonth-day string

-1, 0, or 1, or null on invalid input

import { compareMonthDays } from "@northguild/gmt/plain/compare";
compareMonthDays("--01-01", "--12-31") // -1
output 

plain/compare/compareMonthDays.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.