mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibJS: Fix fallback of hour, minute, second in parse_iso_date_time()
It's not the `to_uint<u8>()` call that would fail, if we have a value for these productions they will always be valid numbers. We do need to provide a fallback for when that's not the case and any of them is undefined, i.e. an empty Optional.
This commit is contained in:
parent
de23f0b68c
commit
9628452550
1 changed files with 3 additions and 3 deletions
|
@ -1105,13 +1105,13 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(GlobalObject& global_object,
|
|||
}
|
||||
|
||||
// 10. Set hour to ! ToIntegerOrInfinity(hour).
|
||||
u8 hour = hour_part->to_uint<u8>().value_or(0);
|
||||
u8 hour = *hour_part.value_or("0"sv).to_uint<u8>();
|
||||
|
||||
// 11. Set minute to ! ToIntegerOrInfinity(minute).
|
||||
u8 minute = minute_part->to_uint<u8>().value_or(0);
|
||||
u8 minute = *minute_part.value_or("0"sv).to_uint<u8>();
|
||||
|
||||
// 12. Set second to ! ToIntegerOrInfinity(second).
|
||||
u8 second = second_part->to_uint<u8>().value_or(0);
|
||||
u8 second = *second_part.value_or("0"sv).to_uint<u8>();
|
||||
|
||||
// 13. If second is 60, then
|
||||
if (second == 60) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue