Skip to content

PlainMonthDay ​

PlainMonthDay represents a recurring month and day. Validation uses leap year 1972 so February 29 remains representable.

Constructing from fields ​

plainMonthDayFromFields(value: PlainMonthDay): Result<PlainMonthDay, TemporalError> validates the month and day fields and returns the validated month-day value. It uses leap year 1972, so February 29 remains valid.

tyrus
import { PlainDate, PlainMonthDay, TemporalError, plainMonthDayFrom, plainMonthDayToPlainDate, plainMonthDayToString } from "tyrus:temporal";

export const example = (): void => {
    const birthday: PlainMonthDay = match plainMonthDayFrom("02-29") { Ok(result) => result, Err(error) => { printError(error.code); return; } };
    const text: string = match plainMonthDayToString(birthday) { Ok(result) => result, Err(error) => { printError(error.code); return; } }; // "02-29"
    const date: PlainDate = match plainMonthDayToPlainDate(birthday, 2028) { Ok(result) => result, Err(error) => { printError(error.code); return; } }; // 2028-02-29
};