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
11 changed files with 19 additions and 19 deletions

View File

@@ -199,8 +199,8 @@ const std::string Task::identifier (bool shortened /* = false */) const
////////////////////////////////////////////////////////////////////////////////
void Task::setAsNow (const std::string& att)
{
char now[16];
snprintf (now, 16, "%u", (unsigned int) time (nullptr));
char now[22];
snprintf (now, 22, "%lli", (long long int) time (nullptr));
set (att, now);
recalc_urgency = true;
@@ -1189,7 +1189,7 @@ void Task::addAnnotation (const std::string& description)
do
{
key = "annotation_" + format ((int) now);
key = "annotation_" + format ((long long int) now);
++now;
}
while (has (key));