summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-08-24 09:23:46 -0400
committerAndreas Kling <kling@serenityos.org>2020-08-24 18:20:07 +0200
commit593b0b9fccbd275ba47b9be9be0f7e63ae58f2ab (patch)
tree2f6076658c263cd7069ad4922ed976bc8033e7be /Libraries/LibCore
parent1c9581f383d947d35d19f7266839fef401b981cb (diff)
downloadserenity-593b0b9fccbd275ba47b9be9be0f7e63ae58f2ab.zip
LibCore: Less code duplication in DateTime
DateTime::create() an just call DateTime::set_time(). No behavior change.
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r--Libraries/LibCore/DateTime.cpp18
1 files changed, 1 insertions, 17 deletions
diff --git a/Libraries/LibCore/DateTime.cpp b/Libraries/LibCore/DateTime.cpp
index fa3da3fd79..fee56d5ee3 100644
--- a/Libraries/LibCore/DateTime.cpp
+++ b/Libraries/LibCore/DateTime.cpp
@@ -39,23 +39,7 @@ DateTime DateTime::now()
DateTime DateTime::create(unsigned year, unsigned month, unsigned day, unsigned hour, unsigned minute, unsigned second)
{
DateTime dt;
- dt.m_year = year;
- dt.m_month = month;
- dt.m_day = day;
- dt.m_hour = hour;
- dt.m_minute = minute;
- dt.m_second = second;
-
- struct tm tm = {};
- tm.tm_sec = (int)second;
- tm.tm_min = (int)minute;
- tm.tm_hour = (int)hour;
- tm.tm_mday = (int)day;
- tm.tm_mon = (int)month - 1;
- tm.tm_year = (int)year - 1900;
- // mktime() doesn't read tm.tm_wday and tm.tm_yday, no need to fill them in.
- dt.m_timestamp = mktime(&tm);
-
+ dt.set_time(year, month, day, hour, minute, second);
return dt;
}