Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimeFormatter creates invalid ISO8601 string #3723

Closed
tomaz-beltram opened this issue Jul 29, 2022 · 3 comments · Fixed by #3769
Closed

DateTimeFormatter creates invalid ISO8601 string #3723

tomaz-beltram opened this issue Jul 29, 2022 · 3 comments · Fixed by #3769
Assignees
Labels

Comments

@tomaz-beltram
Copy link
Contributor

tomaz-beltram commented Jul 29, 2022

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.

@aleks-f
Copy link
Member

aleks-f commented Jul 29, 2022

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

e283643#diff-4ea7e490ca4d6746ecc695f37c15320cc17f3d0cd26a802250b3ccca2565ba13

@tomaz-beltram
Copy link
Contributor Author

tomaz-beltram commented Jul 29, 2022 via email

@aleks-f aleks-f added this to the Release 1.13.0 milestone Jul 29, 2022
@tomaz-beltram
Copy link
Contributor Author

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.

tomaz-beltram pushed a commit to tomaz-beltram/poco that referenced this issue Aug 23, 2022
@aleks-f aleks-f linked a pull request Aug 24, 2022 that will close this issue
aleks-f pushed a commit that referenced this issue Aug 27, 2022
Co-authored-by: Tomaz Beltram <tomaz.beltram@topit.si>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants