Skip to content
Snippets Groups Projects
Unverified Commit acbae572 authored by bunnei's avatar bunnei Committed by GitHub
Browse files

Revert "common/time_zone: Simplify GetOsTimeZoneOffset()"

parent b1fa647f
No related branches found
No related tags found
No related merge requests found
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <chrono> #include <chrono>
#include <ctime> #include <iomanip>
#include <sstream>
#include <fmt/chrono.h>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/time_zone.h" #include "common/time_zone.h"
...@@ -17,8 +16,13 @@ std::string GetDefaultTimeZone() { ...@@ -17,8 +16,13 @@ std::string GetDefaultTimeZone() {
} }
static std::string GetOsTimeZoneOffset() { static std::string GetOsTimeZoneOffset() {
// Get the current timezone offset, e.g. "-400", as a string const std::time_t t{std::time(nullptr)};
return fmt::format("%z", fmt::localtime(std::time(nullptr))); const std::tm tm{*std::localtime(&t)};
std::stringstream ss;
ss << std::put_time(&tm, "%z"); // Get the current timezone offset, e.g. "-400", as a string
return ss.str();
} }
static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment