troldal / OpenXLSX

A C++ library for reading, writing, creating and modifying Microsoft Excel® (.xlsx) files.
BSD 3-Clause "New" or "Revised" License
1.37k stars 333 forks source link

Error in XLDateTime #135

Open LavrenovRoman opened 2 years ago

LavrenovRoman commented 2 years ago

error in file XLDateTime.cpp (line 216) the error in case the last day of month. if serial is 30.71232..... it is mean that the 30th day with some time, but if the month have 30 days then serial -=day and serial = 0.71232 and result.tm_mday will be 0 after that line

The correct code: while (true) { auto days = daysInMonth(result.tm_mon + 1, 1900 + result.tm_year); if (days >= static_cast<int>(serial)) break; //correct //if (days > serial) break; //error serial -= days; ++result.tm_mon; }

gvollant commented 2 years ago

I've included your fix on PR https://github.com/troldal/OpenXLSX/pull/111 @LavrenovRoman