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

@@ -631,7 +631,7 @@ std::string CmdCalendar::renderMonths (
{
if(task.has("scheduled") && !coloredWithDue) {
std::string scheduled = task.get ("scheduled");
Datetime scheduleddmy (strtol (scheduled.c_str(), nullptr, 10));
Datetime scheduleddmy (strtoll (scheduled.c_str(), nullptr, 10));
if (scheduleddmy.sameDay (date))
{
@@ -640,7 +640,7 @@ std::string CmdCalendar::renderMonths (
}
if(task.has("due")) {
std::string due = task.get ("due");
Datetime duedmy (strtol (due.c_str(), nullptr, 10));
Datetime duedmy (strtoll (due.c_str(), nullptr, 10));
if (duedmy.sameDay (date))
{

View File

@@ -261,7 +261,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
for (auto& anno : task.getAnnotations ())
{
Datetime dt (strtol (anno.first.substr (11).c_str (), nullptr, 10));
Datetime dt (strtoll (anno.first.substr (11).c_str (), nullptr, 10));
before << " Annotation: " << dt.toString (dateformat)
<< " -- " << str_replace (anno.second, "\n", ANNOTATION_EDIT_MARKER) << '\n';
}

View File

@@ -240,7 +240,7 @@ int CmdInfo::execute (std::string& output)
auto created = task.get ("entry");
if (created.length ())
{
Datetime dt (strtol (created.c_str (), nullptr, 10));
Datetime dt (strtoll (created.c_str (), nullptr, 10));
age = Duration (now - dt).formatVague ();
}

View File

@@ -109,13 +109,13 @@ int CmdStats::execute (std::string& output)
if (task.is_blocked) ++blockedT;
if (task.is_blocking) ++blockingT;
time_t entry = strtol (task.get ("entry").c_str (), nullptr, 10);
time_t entry = strtoll (task.get ("entry").c_str (), nullptr, 10);
if (entry < earliest) earliest = entry;
if (entry > latest) latest = entry;
if (status == Task::completed)
{
time_t end = strtol (task.get ("end").c_str (), nullptr, 10);
time_t end = strtoll (task.get ("end").c_str (), nullptr, 10);
daysPending += (end - entry) / 86400.0;
}

View File

@@ -109,7 +109,7 @@ int CmdSummary::execute (std::string& output)
{
++countPending[parent];
time_t entry = strtol (task.get ("entry").c_str (), nullptr, 10);
time_t entry = strtoll (task.get ("entry").c_str (), nullptr, 10);
if (entry)
sumEntry[parent] = sumEntry[parent] + (double) (now - entry);
}
@@ -121,8 +121,8 @@ int CmdSummary::execute (std::string& output)
{
++countCompleted[parent];
time_t entry = strtol (task.get ("entry").c_str (), nullptr, 10);
time_t end = strtol (task.get ("end").c_str (), nullptr, 10);
time_t entry = strtoll (task.get ("entry").c_str (), nullptr, 10);
time_t end = strtoll (task.get ("end").c_str (), nullptr, 10);
if (entry && end)
sumEntry[parent] = sumEntry[parent] + (double) (end - entry);
}