1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:17:46 +00:00

LibJS: Implement Temporal.Calendar.prototype.monthCode

This commit is contained in:
Idan Horowitz 2021-07-23 16:56:38 +03:00 committed by Linus Groh
parent a0af9b11fb
commit 9d9ba29cae
5 changed files with 56 additions and 0 deletions

View file

@ -489,4 +489,19 @@ u8 iso_month(Object& temporal_object)
VERIFY_NOT_REACHED();
}
// 12.1.43 ISOMonthCode ( temporalObject ), https://tc39.es/proposal-temporal/#sec-temporal-isomonthcode
String iso_month_code(Object& temporal_object)
{
// 1. Assert: temporalObject has an [[ISOMonth]] internal slot.
// NOTE: Asserted by the VERIFY_NOT_REACHED at the end
// 2. Return ! BuildISOMonthCode(temporalObject.[[ISOMonth]]).
// TODO: add the rest of the builtins with a [[ISOMonth]] slot (PlainYearMonth, PlainMonthDay)
if (is<PlainDate>(temporal_object))
return build_iso_month_code(static_cast<PlainDate&>(temporal_object).iso_month());
if (is<PlainDateTime>(temporal_object))
return build_iso_month_code(static_cast<PlainDateTime&>(temporal_object).iso_month());
VERIFY_NOT_REACHED();
}
}