Fix issues with year 2038 (#3052)

* Fix annotations in year 2038

Fixes #3050

* Ensure 32-bit systems work better after 2038

Without this patch, their 32-bit signed long int could overflow.

This patch was done while working on reproducible builds for openSUSE.
This commit is contained in:
Bernhard M. Wiedemann 2023-08-31 04:08:31 +02:00 committed by GitHub
parent 7017d8fc31
commit 603bf075f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 19 additions and 19 deletions

View file

@ -171,7 +171,7 @@ void ColumnDescription::render (
{
for (const auto& i : task.getAnnotations ())
{
Datetime dt (strtol (i.first.substr (11).c_str (), nullptr, 10));
Datetime dt (strtoll (i.first.substr (11).c_str (), nullptr, 10));
description += '\n' + std::string (_indent, ' ') + dt.toString (_dateformat) + ' ' + i.second;
}
}
@ -200,7 +200,7 @@ void ColumnDescription::render (
{
for (const auto& i : task.getAnnotations ())
{
Datetime dt (strtol (i.first.substr (11).c_str (), nullptr, 10));
Datetime dt (strtoll (i.first.substr (11).c_str (), nullptr, 10));
description += ' ' + dt.toString (_dateformat) + ' ' + i.second;
}
}

View file

@ -241,7 +241,7 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma
// rc.report.<report>.dateformat
// rc.dateformat.report
// rc.dateformat
Datetime date ((time_t) strtol (value.c_str (), nullptr, 10));
Datetime date (strtoll (value.c_str (), nullptr, 10));
auto format = Context::getContext ().config.get ("report." + _report + ".dateformat");
if (format == "")
format = Context::getContext ().config.get ("dateformat.report");
@ -287,7 +287,7 @@ void ColumnUDADate::render (
format = Context::getContext ().config.get ("dateformat");
}
renderStringLeft (lines, width, color, Datetime ((time_t) strtol (value.c_str (), nullptr, 10)).toString (format));
renderStringLeft (lines, width, color, Datetime (strtoll (value.c_str (), nullptr, 10)).toString (format));
}
else if (_style == "indicator")
{