mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
Merge pull request #41 from ToruNiina/hotfix
fix: simplify and correct the format of timezone
This commit is contained in:
@@ -332,17 +332,10 @@ operator<<(std::basic_ostream<charT, traits>& os, const time_offset& offset)
|
|||||||
os << 'Z';
|
os << 'Z';
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
if(static_cast<int>(offset.hour) * static_cast<int>(offset.minute) < 0)
|
int minute = static_cast<int>(offset.hour) * 60 + offset.minute;
|
||||||
{
|
if(minute < 0){os << '-'; minute = std::abs(minute);} else {os << '+';}
|
||||||
const int min = static_cast<int>(offset.hour) * 60 + offset.minute;
|
os << std::setfill('0') << std::setw(2) << minute / 60 << ':';
|
||||||
if(min < 0){os << '-';} else {os << '+';}
|
os << std::setfill('0') << std::setw(2) << minute % 60;
|
||||||
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<int>(offset.hour) << ':';
|
|
||||||
os << std::setfill('0') << std::setw(2) << static_cast<int>(offset.minute);
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user