Explorar el Código

LibJS: Create 1970-01-01 00:00:00 local time Date for invalid ctor call

When using Core::DateTime::from_timestamp(0) the resulting Date is
1970-01-01 00:00:00 in UTC, which might be something different in local
time - this is incorrect and relevant as invalid Dates can be made valid
later on.
Linus Groh hace 4 años
padre
commit
ba9d3bc38c
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      Userland/Libraries/LibJS/Runtime/DateConstructor.cpp

+ 1 - 1
Userland/Libraries/LibJS/Runtime/DateConstructor.cpp

@@ -159,7 +159,7 @@ Value DateConstructor::construct(Function&)
     }
 
     auto create_invalid_date = [this]() {
-        auto datetime = Core::DateTime::from_timestamp(static_cast<time_t>(0));
+        auto datetime = Core::DateTime::create(1970, 1, 1, 0, 0, 0);
         auto milliseconds = static_cast<u16>(0);
         return Date::create(global_object(), datetime, milliseconds, true);
     };