summaryrefslogtreecommitdiff
path: root/src/common/time_zone.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/time_zone.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/common/time_zone.cpp b/src/common/time_zone.cpp
index 7aa1b59ea..ce239eb63 100644
--- a/src/common/time_zone.cpp
+++ b/src/common/time_zone.cpp
@@ -3,9 +3,8 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <chrono> 5#include <chrono>
6#include <ctime> 6#include <iomanip>
7 7#include <sstream>
8#include <fmt/chrono.h>
9 8
10#include "common/logging/log.h" 9#include "common/logging/log.h"
11#include "common/time_zone.h" 10#include "common/time_zone.h"
@@ -17,8 +16,13 @@ std::string GetDefaultTimeZone() {
17} 16}
18 17
19static std::string GetOsTimeZoneOffset() { 18static std::string GetOsTimeZoneOffset() {
20 // Get the current timezone offset, e.g. "-400", as a string 19 const std::time_t t{std::time(nullptr)};
21 return fmt::format("%z", fmt::localtime(std::time(nullptr))); 20 const std::tm tm{*std::localtime(&t)};
21
22 std::stringstream ss;
23 ss << std::put_time(&tm, "%z"); // Get the current timezone offset, e.g. "-400", as a string
24
25 return ss.str();
22} 26}
23 27
24static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { 28static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) {