OpenXLSX
OpenXLSX copied to clipboard
Error in XLDateTime
Hi For serial number 43791.583333333299 returned date (at least hour) is not correct returned hour is 13:59:60 but shall be 14:00:00
/**
* @details Get the time point as a std::tm object.
*/
std::tm XLDateTime::tm() const
// ...
// ===== Calculate the number of days.
result.tm_mday = static_cast<int>(serial);
serial -= result.tm_mday;
// fix calculation accuracy <--
auto tm_sec = static_cast<int>(lround(serial * 24 * 60 * 60));
serial = tm_sec / (24.0 * 60.0 * 60.0);
// ===== Calculate the number of hours.
result.tm_hour = static_cast<int>(serial * 24);
serial -= (result.tm_hour / 24.0);
// ...