UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

23 lines (22 loc) • 904 B
// src/internal/monthDay.ts /** * The ISO reference year of every `Temporal.PlainMonthDay` GMT builds: 1972. * * Temporal fixes it in the `PlainMonthDay` constructor and ToTemporalMonthDay: "Set * _referenceISOYear_ to 1972 (the first ISO 8601 leap year after the epoch)". It is a leap year, * so `--02-29` exists in it. GMT uses it to compare and to format, and never prints it. */ const REFERENCE_ISO_YEAR = 1972; /** * The canonical `--MM-DD` string of a month-day: Temporal's `MM-DD` with the `--` of RFC 3339 * Appendix A (`datespec-mday`) in front. The reference year is never written. * * @param monthDay an ISO-calendar `PlainMonthDay` * @returns the `--MM-DD` string * * @example monthDayString(Temporal.PlainMonthDay.from("12-25")) // "--12-25" */ function monthDayString(monthDay) { return `--${monthDay.toString({ calendarName: "never" })}`; } export { REFERENCE_ISO_YEAR, monthDayString };