poco
poco copied to clipboard
DateTimeFormatter creates invalid ISO8601 string
Describe the bug Crating a Poco::Timestamp from Poco::DateTime and using Poco::DateTimeFormatter::format() creates invalid ISODate with negative hour, minute and second values for timestamps before October 15, 1582.
To Reproduce
std::string orig("1582-10-14T00:00:01Z");
Poco::DateTime dateTime;
int tzd;
Poco::DateTimeParser::tryParse(Poco::DateTimeFormat::ISO8601_FRAC_FORMAT, orig, dateTime, tzd);
const auto pts = dateTime.timestamp();
auto fmt = Poco::DateTimeFormatter::format(pts, Poco::DateTimeFormat::ISO8601_FRAC_FORMAT);
Expected behavior Expected result is "1582-10-14T00:00:01.000000Z" instead of "1582-10-14T-23:-59:-59.000000Z" which is invalid ISODate.
Logs If applicable, add logs to help explain your problem.
Screenshots If applicable, add screenshots to help explain your problem.
Please add relevant environment information:
- OS Ubuntu 20.04
- POCO 1.10.1
Additional context I'm not sure if this is a bug or limitation of allowed Poco::Timestamp date range. Interesting is that the year, month and date are properly formatted from Poco::Timestamp value and just the hour, minute and second become negative.
I really have no time to investigate and fix it, but if you can look deeper (and perhaps if items below from develop-experimental
are somehow related), and send a pull, I'll schedule this for 1.13:
https://github.com/pocoproject/poco/issues/569
https://github.com/pocoproject/poco/commit/e2836431ae71b734184423426fa734735bd18052#diff-4ea7e490ca4d6746ecc695f37c15320cc17f3d0cd26a802250b3ccca2565ba13
I can do that. Thanks for pointing out related items. V pet., 29. jul. 2022 15:41 je oseba Aleksandar Fabijanic < @.***> napisala:
I really have no time to investigate and fix it, but if you can look deeper (and perhaps if items below from develop-experimental are somehow related), and send a pull, I'll schedule this for 1.13:
#569 https://github.com/pocoproject/poco/issues/569
e283643 #diff-4ea7e490ca4d6746ecc695f37c15320cc17f3d0cd26a802250b3ccca2565ba13 https://github.com/pocoproject/poco/commit/e2836431ae71b734184423426fa734735bd18052#diff-4ea7e490ca4d6746ecc695f37c15320cc17f3d0cd26a802250b3ccca2565ba13
— Reply to this email directly, view it on GitHub https://github.com/pocoproject/poco/issues/3723#issuecomment-1199301096, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVM75G2PGDV26H5ILCZNVDVWPNSFANCNFSM55AOVRKQ . You are receiving this because you authored the thread.Message ID: @.***>
Poco::DateTime class stores a date/time in two forms (UTC and broken down). The UTC form starts from beginning of Gregorian calender with 100 nanosecond resolution. The value is negative for dates before October 15, 1582. Its used to update hour, miunute, second,... values in DateTime::computeDaytime() producing negative values.