From bba54e1880bd70d634797052d78359e30ec79acd Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 12 May 2020 18:44:07 -0400 Subject: [PATCH] time_zone: Use std::chrono::seconds for strong typing. --- src/common/time_zone.cpp | 4 ++-- src/common/time_zone.h | 3 ++- src/core/hle/service/time/time_manager.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/common/time_zone.cpp b/src/common/time_zone.cpp index b902d2d471..ce239eb63f 100644 --- a/src/common/time_zone.cpp +++ b/src/common/time_zone.cpp @@ -37,13 +37,13 @@ static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { } } -int GetCurrentOffsetSeconds() { +std::chrono::seconds GetCurrentOffsetSeconds() { const int offset{ConvertOsTimeZoneOffsetToInt(GetOsTimeZoneOffset())}; int seconds{(offset / 100) * 60 * 60}; // Convert hour component to seconds seconds += (offset % 100) * 60; // Convert minute component to seconds - return seconds; + return std::chrono::seconds{seconds}; } } // namespace Common::TimeZone diff --git a/src/common/time_zone.h b/src/common/time_zone.h index b7aa1bb108..945daa09ce 100644 --- a/src/common/time_zone.h +++ b/src/common/time_zone.h @@ -4,6 +4,7 @@ #pragma once +#include #include namespace Common::TimeZone { @@ -12,6 +13,6 @@ namespace Common::TimeZone { std::string GetDefaultTimeZone(); /// Gets the offset of the current timezone (from the default), in seconds -int GetCurrentOffsetSeconds(); +std::chrono::seconds GetCurrentOffsetSeconds(); } // namespace Common::TimeZone diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index 54f4a3f049..b4dfe45e5e 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp @@ -25,7 +25,7 @@ static std::chrono::seconds GetSecondsSinceEpoch() { static s64 GetExternalTimeZoneOffset() { // With "auto" timezone setting, we use the external system's timezone offset if (Settings::GetTimeZoneString() == "auto") { - return Common::TimeZone::GetCurrentOffsetSeconds(); + return Common::TimeZone::GetCurrentOffsetSeconds().count(); } return 0; }