mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
LibJS: Convert get_iana_time_zone_epoch_value() to MarkedVector<BigInt*>
This commit is contained in:
parent
af7003ebd2
commit
1d32ac7b8b
3 changed files with 4 additions and 5 deletions
|
@ -144,15 +144,14 @@ ISODateTime get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds)
|
|||
}
|
||||
|
||||
// 11.6.3 GetIANATimeZoneEpochValue ( timeZoneIdentifier, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond ), https://tc39.es/proposal-temporal/#sec-temporal-getianatimezoneepochvalue
|
||||
MarkedValueList get_iana_time_zone_epoch_value(GlobalObject& global_object, [[maybe_unused]] StringView time_zone_identifier, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond)
|
||||
MarkedVector<BigInt*> get_iana_time_zone_epoch_value(GlobalObject& global_object, [[maybe_unused]] StringView time_zone_identifier, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond)
|
||||
{
|
||||
// The abstract operation GetIANATimeZoneEpochValue is an implementation-defined algorithm that returns a List of integers. Each integer in the List represents a number of nanoseconds since the Unix epoch in UTC that may correspond to the given calendar date and wall-clock time in the IANA time zone identified by timeZoneIdentifier.
|
||||
// When the input represents a local time repeating multiple times at a negative time zone transition (e.g. when the daylight saving time ends or the time zone offset is decreased due to a time zone rule change), the returned List will have more than one element. When the input represents a skipped local time at a positive time zone transition (e.g. when the daylight saving time starts or the time zone offset is increased due to a time zone rule change), the returned List will be empty. Otherwise, the returned List will have one element.
|
||||
|
||||
// FIXME: Implement this properly for non-UTC timezones.
|
||||
// FIXME: MarkedValueList<T> for T != Value would still be nice.
|
||||
auto& vm = global_object.vm();
|
||||
auto list = MarkedValueList { vm.heap() };
|
||||
auto list = MarkedVector<BigInt*> { vm.heap() };
|
||||
list.append(get_epoch_from_iso_parts(global_object, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond));
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ String default_time_zone();
|
|||
ThrowCompletionOr<String> parse_temporal_time_zone(GlobalObject&, String const&);
|
||||
ThrowCompletionOr<TimeZone*> create_temporal_time_zone(GlobalObject&, String const& identifier, FunctionObject const* new_target = nullptr);
|
||||
ISODateTime get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds);
|
||||
MarkedValueList get_iana_time_zone_epoch_value(GlobalObject&, StringView time_zone_identifier, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond);
|
||||
MarkedVector<BigInt*> get_iana_time_zone_epoch_value(GlobalObject&, StringView time_zone_identifier, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond);
|
||||
i64 get_iana_time_zone_offset_nanoseconds(BigInt const& epoch_nanoseconds, String const& time_zone_identifier);
|
||||
BigInt* get_iana_time_zone_next_transition(GlobalObject&, BigInt const& epoch_nanoseconds, StringView time_zone_identifier);
|
||||
BigInt* get_iana_time_zone_previous_transition(GlobalObject&, BigInt const& epoch_nanoseconds, StringView time_zone_identifier);
|
||||
|
|
|
@ -156,7 +156,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_possible_instants_for)
|
|||
// 7. For each value epochNanoseconds in possibleEpochNanoseconds, do
|
||||
for (auto& epoch_nanoseconds : possible_epoch_nanoseconds) {
|
||||
// a. Let instant be ! CreateTemporalInstant(epochNanoseconds).
|
||||
auto* instant = MUST(create_temporal_instant(global_object, epoch_nanoseconds.as_bigint()));
|
||||
auto* instant = MUST(create_temporal_instant(global_object, *epoch_nanoseconds));
|
||||
|
||||
// b. Append instant to possibleInstants.
|
||||
possible_instants.append(instant);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue