mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:17:35 +00:00
LibJS: Check for invalid epoch nanoseconds in getPossibleInstantsFor()
This is a normative change in the Temporal spec.
See: 439e6af
This commit is contained in:
parent
61bdbe712e
commit
d10e0f0e3e
1 changed files with 6 additions and 2 deletions
|
@ -157,10 +157,14 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_possible_instants_for)
|
||||||
|
|
||||||
// 7. For each value epochNanoseconds in possibleEpochNanoseconds, do
|
// 7. For each value epochNanoseconds in possibleEpochNanoseconds, do
|
||||||
for (auto& epoch_nanoseconds : possible_epoch_nanoseconds) {
|
for (auto& epoch_nanoseconds : possible_epoch_nanoseconds) {
|
||||||
// a. Let instant be ! CreateTemporalInstant(epochNanoseconds).
|
// a. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception.
|
||||||
|
if (!is_valid_epoch_nanoseconds(*epoch_nanoseconds))
|
||||||
|
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds);
|
||||||
|
|
||||||
|
// b. Let instant be ! CreateTemporalInstant(epochNanoseconds).
|
||||||
auto* instant = MUST(create_temporal_instant(global_object, *epoch_nanoseconds));
|
auto* instant = MUST(create_temporal_instant(global_object, *epoch_nanoseconds));
|
||||||
|
|
||||||
// b. Append instant to possibleInstants.
|
// c. Append instant to possibleInstants.
|
||||||
possible_instants.append(instant);
|
possible_instants.append(instant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue