mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
add restriction to datetime offset size
This commit is contained in:
@@ -117,9 +117,12 @@ basic_datetime<uT, iT>::basic_datetime(std::chrono::system_clock::time_point tp)
|
|||||||
>(diff).count() % 1000;
|
>(diff).count() % 1000;
|
||||||
|
|
||||||
std::tm *utc = std::gmtime(&t);
|
std::tm *utc = std::gmtime(&t);
|
||||||
|
int total_offset = (this->hour - utc->tm_hour) * 60 +
|
||||||
offset_hour = this->hour - utc->tm_hour;
|
(this->minute - utc->tm_min);
|
||||||
offset_minute = this->minute - utc->tm_min;
|
if(total_offset > 720) total_offset -= 1440;
|
||||||
|
else if(total_offset < -720) total_offset += 1440;
|
||||||
|
offset_hour = total_offset / 60;
|
||||||
|
offset_minute = total_offset - (offset_hour * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename uT, typename iT>
|
template<typename uT, typename iT>
|
||||||
|
Reference in New Issue
Block a user