mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-12-16 03:08:52 +08:00
fix datetime::ctor and stream operator for datetime
This commit is contained in:
@@ -84,12 +84,8 @@ struct basic_datetime
|
|||||||
auto tp = std::chrono::system_clock::from_time_t(mktime(&time));
|
auto tp = std::chrono::system_clock::from_time_t(mktime(&time));
|
||||||
tp += std::chrono::milliseconds(this->millisecond);
|
tp += std::chrono::milliseconds(this->millisecond);
|
||||||
tp += std::chrono::microseconds(this->microsecond);
|
tp += std::chrono::microseconds(this->microsecond);
|
||||||
|
// mktime regards the tm struct as localtime. so adding offset is not needed.
|
||||||
|
|
||||||
if(this->offset_hour != nooffset && this->offset_minute != nooffset)
|
|
||||||
{
|
|
||||||
tp += std::chrono::hours(this->offset_hour);
|
|
||||||
tp += std::chrono::minutes(this->offset_minute);
|
|
||||||
}
|
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
operator std::time_t() const
|
operator std::time_t() const
|
||||||
@@ -171,8 +167,8 @@ operator<<(std::basic_ostream<charT, traits>& os, basic_datetime<uT, iT> const&
|
|||||||
if(om > 0) sign = '+'; else sign='-';
|
if(om > 0) sign = '+'; else sign='-';
|
||||||
oh = om / 60;
|
oh = om / 60;
|
||||||
om -= oh * 60;
|
om -= oh * 60;
|
||||||
os << sign << std::setfill('0') << std::setw(2) << oh << ':'
|
os << sign << std::setfill('0') << std::setw(2) << std::abs(oh) << ':'
|
||||||
<< std::setfill('0') << std::setw(2) << om;
|
<< std::setfill('0') << std::setw(2) << std::abs(om);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return os;
|
return os;
|
||||||
|
|||||||
Reference in New Issue
Block a user