mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-27 16:09:05 +08:00
Fixed issue #266 (Improperly-formatted ISO8601 UTC offset for negative-offset timezones)
This commit is contained in:
parent
bf327be7f5
commit
cb75569541
@ -319,13 +319,21 @@ public:
|
|||||||
// it is very fast (already stored in tm.tm_gmtoff)
|
// it is very fast (already stored in tm.tm_gmtoff)
|
||||||
int total_minutes = os::utc_minutes_offset(tm_time);
|
int total_minutes = os::utc_minutes_offset(tm_time);
|
||||||
#endif
|
#endif
|
||||||
|
bool is_negative = total_minutes < 0;
|
||||||
|
char sign;
|
||||||
|
if (is_negative)
|
||||||
|
{
|
||||||
|
total_minutes = -total_minutes;
|
||||||
|
sign = '-';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sign = '+';
|
||||||
|
}
|
||||||
|
|
||||||
int h = total_minutes / 60;
|
int h = total_minutes / 60;
|
||||||
int m = total_minutes % 60;
|
int m = total_minutes % 60;
|
||||||
if (h >= 0) //minus sign will be printed anyway if negative
|
msg.formatted << sign;
|
||||||
{
|
|
||||||
msg.formatted << '+';
|
|
||||||
}
|
|
||||||
pad_n_join(msg.formatted, h, m, ':');
|
pad_n_join(msg.formatted, h, m, ':');
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user