mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
LibJS: Change GetISOPartsFromEpoch's return type to ISODateTime
This AO can't throw so its optional is never empty.
This commit is contained in:
parent
1822b2938e
commit
830d484d78
2 changed files with 5 additions and 5 deletions
|
@ -115,7 +115,7 @@ TimeZone* create_temporal_time_zone(GlobalObject& global_object, String const& i
|
|||
}
|
||||
|
||||
// 11.6.3 GetISOPartsFromEpoch ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal-getisopartsfromepoch
|
||||
Optional<ISODateTime> get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds)
|
||||
ISODateTime get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds)
|
||||
{
|
||||
// 1. Let remainderNs be remainder(epochNanoseconds, 10^6).
|
||||
auto remainder_ns_bigint = epoch_nanoseconds.big_integer().divided_by(Crypto::UnsignedBigInteger { 1'000'000 }).remainder;
|
||||
|
@ -153,7 +153,7 @@ Optional<ISODateTime> get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds)
|
|||
auto nanosecond = static_cast<u16>(remainder_ns % 1000);
|
||||
|
||||
// 12. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.
|
||||
return ISODateTime { .year = year, .month = month, .day = day, .hour = hour, .minute = minute, .second = second, .millisecond = millisecond, .microsecond = microsecond, .nanosecond = nanosecond };
|
||||
return { .year = year, .month = month, .day = day, .hour = hour, .minute = minute, .second = second, .millisecond = millisecond, .microsecond = microsecond, .nanosecond = nanosecond };
|
||||
}
|
||||
|
||||
// 11.6.5 GetIANATimeZoneOffsetNanoseconds ( epochNanoseconds, timeZoneIdentifier ), https://tc39.es/proposal-temporal/#sec-temporal-getianatimezoneoffsetnanoseconds
|
||||
|
@ -439,10 +439,10 @@ PlainDateTime* builtin_time_zone_get_plain_date_time_for(GlobalObject& global_ob
|
|||
auto result = get_iso_parts_from_epoch(instant.nanoseconds());
|
||||
|
||||
// 3. Set result to ! BalanceISODateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]] + offsetNanoseconds).
|
||||
result = balance_iso_date_time(result->year, result->month, result->day, result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond + offset_nanoseconds);
|
||||
result = balance_iso_date_time(result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond + offset_nanoseconds);
|
||||
|
||||
// 4. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], calendar).
|
||||
return create_temporal_date_time(global_object, result->year, result->month, result->day, result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond, calendar);
|
||||
return create_temporal_date_time(global_object, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, calendar);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ String canonicalize_time_zone_name(String const& time_zone);
|
|||
String default_time_zone();
|
||||
String parse_temporal_time_zone(GlobalObject&, String const&);
|
||||
TimeZone* create_temporal_time_zone(GlobalObject&, String const& identifier, FunctionObject const* new_target = nullptr);
|
||||
Optional<ISODateTime> get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds);
|
||||
ISODateTime get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds);
|
||||
i64 get_iana_time_zone_offset_nanoseconds(BigInt const& epoch_nanoseconds, String const& time_zone_identifier);
|
||||
double parse_time_zone_offset_string(GlobalObject&, String const&);
|
||||
String format_time_zone_offset_string(double offset_nanoseconds);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue