From 57dcc71fc5cb600a3189462b1e49cbc871225abb Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Tue, 19 Dec 2017 17:25:02 -0500 Subject: [PATCH] Two more imports eliminated --- std/datetime/timezone.d | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/std/datetime/timezone.d b/std/datetime/timezone.d index 176745e149a..b59ae755528 100644 --- a/std/datetime/timezone.d +++ b/std/datetime/timezone.d @@ -20,11 +20,6 @@ version(Windows) // for updating the translations. // version = UpdateWindowsTZTranslations; } -else version(Posix) -{ - import core.sys.posix.signal : timespec; - import core.sys.posix.sys.types : time_t; -} version(unittest) import std.exception : assertThrown; @@ -257,7 +252,7 @@ public: static void testTM(in SysTime st) { import core.stdc.time : localtime, tm; - time_t unixTime = st.toUnixTime(); + auto unixTime = st.toUnixTime(); tm* osTimeInfo = localtime(&unixTime); tm ourTimeInfo = st.toTM(); @@ -852,7 +847,7 @@ public: { import core.stdc.time : localtime, tm; import std.datetime.systime : stdTimeToUnixTime; - time_t unixTime = stdTimeToUnixTime(stdTime); + auto unixTime = stdTimeToUnixTime(stdTime); version(Posix) { @@ -906,7 +901,7 @@ public: { import core.stdc.time : localtime, tm; import std.datetime.systime : stdTimeToUnixTime; - time_t unixTime = stdTimeToUnixTime(stdTime); + auto unixTime = stdTimeToUnixTime(stdTime); tm* timeInfo = localtime(&unixTime); return stdTime + convert!("seconds", "hnsecs")(timeInfo.tm_gmtoff); @@ -943,8 +938,9 @@ public: version(Posix) { import core.stdc.time : localtime, tm; + import core.sys.posix.sys.types : time_t; import std.datetime.systime : stdTimeToUnixTime; - time_t unixTime = stdTimeToUnixTime(adjTime); + auto unixTime = stdTimeToUnixTime(adjTime); immutable past = unixTime - cast(time_t) convert!("days", "seconds")(1); tm* timeInfo = localtime(past < unixTime ? &past : &unixTime); @@ -1151,7 +1147,7 @@ private: import core.stdc.time : localtime, gmtime, tm; import std.datetime.systime : stdTimeToUnixTime; - time_t unixTime = stdTimeToUnixTime(stdTime); + auto unixTime = stdTimeToUnixTime(stdTime); tm* buf = localtime(&unixTime); tm timeInfo = *buf; buf = gmtime(&unixTime); @@ -1978,7 +1974,7 @@ public: immutable leapSecs = calculateLeapSeconds(adjTime); import std.datetime.systime : stdTimeToUnixTime; - time_t unixTime = stdTimeToUnixTime(adjTime); + auto unixTime = stdTimeToUnixTime(adjTime); immutable past = unixTime - convert!("days", "seconds")(1); immutable future = unixTime + convert!("days", "seconds")(1);