From 66e27a94b65d56c705e3541a41860df33fac2b67 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sun, 17 Mar 2019 21:14:17 +0900 Subject: [PATCH] fix: simplify and correct the format of timezone --- toml/datetime.hpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/toml/datetime.hpp b/toml/datetime.hpp index 8c4cc3b..193640d 100644 --- a/toml/datetime.hpp +++ b/toml/datetime.hpp @@ -332,17 +332,10 @@ operator<<(std::basic_ostream& os, const time_offset& offset) os << 'Z'; return os; } - if(static_cast(offset.hour) * static_cast(offset.minute) < 0) - { - const int min = static_cast(offset.hour) * 60 + offset.minute; - if(min < 0){os << '-';} else {os << '+';} - os << std::setfill('0') << std::setw(2) << min / 60 << ':'; - os << std::setfill('0') << std::setw(2) << min % 60; - return os; - } - if(offset.hour < 0){os << '-';} else {os << '+';} - os << std::setfill('0') << std::setw(2) << static_cast(offset.hour) << ':'; - os << std::setfill('0') << std::setw(2) << static_cast(offset.minute); + int minute = static_cast(offset.hour) * 60 + offset.minute; + if(minute < 0){os << '-'; minute = std::abs(minute);} else {os << '+';} + os << std::setfill('0') << std::setw(2) << minute / 60 << ':'; + os << std::setfill('0') << std::setw(2) << minute % 60; return os; }