1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:07:36 +00:00

LibJS: Remove Core::DateTime logic from the Date object :^)

This commit is contained in:
Timothy Flynn 2022-01-14 17:58:49 -05:00 committed by Linus Groh
parent 58ccca6a9d
commit 34a1dd4257
2 changed files with 0 additions and 124 deletions

View file

@ -16,24 +16,11 @@
namespace JS {
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());
}
Date* Date::create(GlobalObject& global_object, double date_value)
{
return global_object.heap().allocate<Date>(global_object, date_value, *global_object.date_prototype());
}
Date::Date(Core::DateTime datetime, i16 milliseconds, bool is_invalid, Object& prototype)
: Object(prototype)
, m_datetime(datetime)
, m_milliseconds(milliseconds)
, m_is_invalid(is_invalid)
{
}
Date::Date(double date_value, Object& prototype)
: Object(prototype)
, m_date_value(date_value)
@ -44,56 +31,6 @@ Date::~Date()
{
}
tm Date::to_utc_tm() const
{
time_t timestamp = m_datetime.timestamp();
struct tm tm;
gmtime_r(&timestamp, &tm);
return tm;
}
int Date::utc_date() const
{
return to_utc_tm().tm_mday;
}
int Date::utc_day() const
{
return to_utc_tm().tm_wday;
}
int Date::utc_full_year() const
{
return to_utc_tm().tm_year + 1900;
}
int Date::utc_hours() const
{
return to_utc_tm().tm_hour;
}
int Date::utc_minutes() const
{
return to_utc_tm().tm_min;
}
int Date::utc_month() const
{
return to_utc_tm().tm_mon;
}
int Date::utc_seconds() const
{
return to_utc_tm().tm_sec;
}
String Date::gmt_date_string() const
{
// Mon, 18 Dec 1995 17:28:35 GMT
// FIXME: Note that we're totally cheating with the timezone part here..
return datetime().to_string("%a, %e %b %Y %T GMT");
}
String Date::iso_date_string() const
{
int year = year_from_time(m_date_value);