1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

LibJS Date: Added "Invalid Date".

Setting an invalid value on a Date object now makes it invalid.
Setting it again but with correct values makes it valid again.
This commit is contained in:
Petróczi Zoltán 2021-03-16 15:02:16 +01:00 committed by Andreas Kling
parent d231c5e65b
commit ca49f96b78
29 changed files with 490 additions and 89 deletions

View file

@ -32,15 +32,16 @@
namespace JS {
Date* Date::create(GlobalObject& global_object, Core::DateTime datetime, u16 milliseconds)
Date* Date::create(GlobalObject& global_object, Core::DateTime datetime, u16 milliseconds, bool is_invalid)
{
return global_object.heap().allocate<Date>(global_object, datetime, milliseconds, *global_object.date_prototype());
return global_object.heap().allocate<Date>(global_object, datetime, milliseconds, is_invalid, *global_object.date_prototype());
}
Date::Date(Core::DateTime datetime, u16 milliseconds, Object& prototype)
Date::Date(Core::DateTime datetime, u16 milliseconds, bool is_invalid, Object& prototype)
: Object(prototype)
, m_datetime(datetime)
, m_milliseconds(milliseconds)
, m_is_invalid(is_invalid)
{
}