time_zone: Use std::chrono::seconds for strong typing.
This commit is contained in:
		| @@ -37,13 +37,13 @@ static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| int GetCurrentOffsetSeconds() { | std::chrono::seconds GetCurrentOffsetSeconds() { | ||||||
|     const int offset{ConvertOsTimeZoneOffsetToInt(GetOsTimeZoneOffset())}; |     const int offset{ConvertOsTimeZoneOffsetToInt(GetOsTimeZoneOffset())}; | ||||||
|  |  | ||||||
|     int seconds{(offset / 100) * 60 * 60}; // Convert hour component to seconds |     int seconds{(offset / 100) * 60 * 60}; // Convert hour component to seconds | ||||||
|     seconds += (offset % 100) * 60;        // Convert minute component to seconds |     seconds += (offset % 100) * 60;        // Convert minute component to seconds | ||||||
|  |  | ||||||
|     return seconds; |     return std::chrono::seconds{seconds}; | ||||||
| } | } | ||||||
|  |  | ||||||
| } // namespace Common::TimeZone | } // namespace Common::TimeZone | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ | |||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
|  | #include <chrono> | ||||||
| #include <string> | #include <string> | ||||||
|  |  | ||||||
| namespace Common::TimeZone { | namespace Common::TimeZone { | ||||||
| @@ -12,6 +13,6 @@ namespace Common::TimeZone { | |||||||
| std::string GetDefaultTimeZone(); | std::string GetDefaultTimeZone(); | ||||||
|  |  | ||||||
| /// Gets the offset of the current timezone (from the default), in seconds | /// Gets the offset of the current timezone (from the default), in seconds | ||||||
| int GetCurrentOffsetSeconds(); | std::chrono::seconds GetCurrentOffsetSeconds(); | ||||||
|  |  | ||||||
| } // namespace Common::TimeZone | } // namespace Common::TimeZone | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ static std::chrono::seconds GetSecondsSinceEpoch() { | |||||||
| static s64 GetExternalTimeZoneOffset() { | static s64 GetExternalTimeZoneOffset() { | ||||||
|     // With "auto" timezone setting, we use the external system's timezone offset |     // With "auto" timezone setting, we use the external system's timezone offset | ||||||
|     if (Settings::GetTimeZoneString() == "auto") { |     if (Settings::GetTimeZoneString() == "auto") { | ||||||
|         return Common::TimeZone::GetCurrentOffsetSeconds(); |         return Common::TimeZone::GetCurrentOffsetSeconds().count(); | ||||||
|     } |     } | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bunnei
					bunnei