diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-11-26 06:14:13 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-11-26 06:14:13 -0500 |
| commit | e67381b4b8731d80a4f11fb441d46424b571a659 (patch) | |
| tree | 36887286596eeb2f4399b6906b99335741835725 /src | |
| parent | 255f96ce7e27124f1bed071564e67a2e4a25c8aa (diff) | |
log timezone
Diffstat (limited to 'src')
| -rw-r--r-- | src/env.cpp | 44 | ||||
| -rw-r--r-- | src/env.h | 4 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/env.cpp b/src/env.cpp index 507607d1..a23e65a4 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -104,10 +104,54 @@ const Metrics& Environment::metrics() const return *m_metrics; } +QString Environment::timezone() const +{ + TIME_ZONE_INFORMATION tz = {}; + + const auto r = GetTimeZoneInformation(&tz); + if (r == TIME_ZONE_ID_INVALID) { + const auto e = GetLastError(); + log::error("failed to get timezone, {}", formatSystemMessage(e)); + return "unknown"; + } + + auto offsetString = [](int o) { + return + QString("%1%2:%3") + .arg(o < 0 ? "" : "+") + .arg(QString::number(o / 60), 2, QChar::fromLatin1('0')) + .arg(QString::number(o % 60), 2, QChar::fromLatin1('0')); + }; + + const auto stdName = QString::fromWCharArray(tz.StandardName); + const auto stdOffset = -(tz.Bias + tz.StandardBias); + const auto std = QString("%1, %2") + .arg(stdName) + .arg(offsetString(stdOffset)); + + const auto dstName = QString::fromWCharArray(tz.DaylightName); + const auto dstOffset = -(tz.Bias + tz.DaylightBias); + const auto dst = QString("%1, %2") + .arg(dstName) + .arg(offsetString(dstOffset)); + + QString s; + + if (r == TIME_ZONE_ID_DAYLIGHT) { + s = dst + " (dst is active, std is " + std + ")"; + } else { + s = std + " (std is active, dst is " + dst + ")"; + } + + return s; +} + void Environment::dump(const Settings& s) const { log::debug("windows: {}", windowsInfo().toString()); + log::debug("time zone: {}", timezone()); + if (windowsInfo().compatibilityMode()) { log::warn("MO seems to be running in compatibility mode"); } @@ -147,6 +147,10 @@ public: // const Metrics& metrics() const; + // timezone + // + QString timezone() const; + // logs the environment // void dump(const Settings& s) const; |
