mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +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
3 changed files with 10 additions and 10 deletions
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
Date* Date::create(GlobalObject& global_object, Core::DateTime datetime, u16 milliseconds, bool is_invalid)
|
||||
Date* Date::create(GlobalObject& global_object, Core::DateTime datetime, i16 milliseconds, bool is_invalid)
|
||||
{
|
||||
return global_object.heap().allocate<Date>(global_object, datetime, milliseconds, is_invalid, *global_object.date_prototype());
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ Date* Date::now(GlobalObject& global_object)
|
|||
struct timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
auto datetime = Core::DateTime::now();
|
||||
auto milliseconds = static_cast<u16>(tv.tv_usec / 1000);
|
||||
auto milliseconds = static_cast<i16>(tv.tv_usec / 1000);
|
||||
return create(global_object, datetime, milliseconds);
|
||||
}
|
||||
|
||||
Date::Date(Core::DateTime datetime, u16 milliseconds, bool is_invalid, Object& prototype)
|
||||
Date::Date(Core::DateTime datetime, i16 milliseconds, bool is_invalid, Object& prototype)
|
||||
: Object(prototype)
|
||||
, m_datetime(datetime)
|
||||
, m_milliseconds(milliseconds)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue