mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-23 19:00:59 +00:00
LibJS: Store Date milliseconds as signed to support negative offsets
We need to support the range of -999 to 999.
This commit is contained in:
parent
17afe015a5
commit
46214f0657
Notes:
sideshowbarker
2024-07-18 12:44:34 +09:00
Author: https://github.com/IdanHo
Commit: 46214f0657
Pull-request: https://github.com/SerenityOS/serenity/pull/7845
Reviewed-by: https://github.com/linusg
3 changed files with 10 additions and 10 deletions
|
@ -152,7 +152,7 @@ Value DateConstructor::construct(Function&)
|
|||
|
||||
auto create_invalid_date = [this]() {
|
||||
auto datetime = Core::DateTime::create(1970, 1, 1, 0, 0, 0);
|
||||
auto milliseconds = static_cast<u16>(0);
|
||||
auto milliseconds = static_cast<i16>(0);
|
||||
return Date::create(global_object(), datetime, milliseconds, true);
|
||||
};
|
||||
|
||||
|
@ -173,7 +173,7 @@ Value DateConstructor::construct(Function&)
|
|||
// A timestamp since the epoch, in UTC.
|
||||
double value_as_double = value.as_double();
|
||||
auto datetime = Core::DateTime::from_timestamp(static_cast<time_t>(value_as_double / 1000));
|
||||
auto milliseconds = static_cast<u16>(fmod(value_as_double, 1000));
|
||||
auto milliseconds = static_cast<i16>(fmod(value_as_double, 1000));
|
||||
return Date::create(global_object(), datetime, milliseconds);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue