mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:37:44 +00:00
LibJS: Implement Temporal.Calendar.prototype.year
This commit is contained in:
parent
9fa8f19a0f
commit
3895a8354d
5 changed files with 59 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <LibJS/Runtime/Temporal/Calendar.h>
|
||||
#include <LibJS/Runtime/Temporal/CalendarConstructor.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainDate.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
@ -416,4 +417,19 @@ Optional<TemporalDate> iso_date_from_fields(GlobalObject& global_object, Object&
|
|||
return regulate_iso_date(global_object, year.as_double(), month, day.as_double(), *overflow);
|
||||
}
|
||||
|
||||
// 12.1.41 ISOYear ( temporalObject ), https://tc39.es/proposal-temporal/#sec-temporal-isoyear
|
||||
i32 iso_year(Object& temporal_object)
|
||||
{
|
||||
// 1. Assert: temporalObject has an [[ISOYear]] internal slot.
|
||||
// NOTE: Asserted by the VERIFY_NOT_REACHED at the end
|
||||
|
||||
// 2. Return 𝔽(temporalObject.[[ISOYear]]).
|
||||
// TODO: add the rest of the builtins with a [[ISOYear]] slot (PlainYearMonth, PlainMonthDay)
|
||||
if (is<PlainDate>(temporal_object))
|
||||
return static_cast<PlainDate&>(temporal_object).iso_year();
|
||||
if (is<PlainDateTime>(temporal_object))
|
||||
return static_cast<PlainDateTime&>(temporal_object).iso_year();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue