Skip to content

Commit

Permalink
Fixed the display of timezone offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel K. O. (dkosmari) committed May 31, 2024
1 parent a603478 commit f16dee5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "http_client.hpp"


using namespace std::literals;


namespace utils {

std::string
Expand Down Expand Up @@ -98,9 +101,10 @@ namespace utils {
tz_offset_to_string(std::chrono::minutes offset)
{
char buf[32];
int hours = offset.count() / 60;
char sign = offset < 0min ? '-' : '+';
int hours = std::abs(offset.count() / 60);
int minutes = std::abs(offset.count() % 60);
std::snprintf(buf, sizeof buf, "%+03d:%02d", hours, minutes);
std::snprintf(buf, sizeof buf, "%c%02d:%02d", sign, hours, minutes);
return buf;
}

Expand Down

0 comments on commit f16dee5

Please sign in to comment.