[4.4] Determine the next task run date with the timezone of the site (#43259)

* Determine the next task run date with the timezone of the site

* cs

---------
This commit is contained in:
Allon Moritz 2024-04-26 20:26:08 +02:00 committed by GitHub
parent 079047c366
commit d1bef331ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -104,7 +104,8 @@ class ExecRuleHelper
case 'cron-expression':
// @todo: testing
$cExp = new CronExpression((string) $this->rule->exp);
$nextExec = $cExp->getNextRunDate('now', 0, false, 'UTC');
$nextExec = $cExp->getNextRunDate('now', 0, false, Factory::getApplication()->get('offset', 'UTC'));
$nextExec->setTimezone(new \DateTimeZone('UTC'));
$nextExec = $string ? $this->dateTimeToSql($nextExec) : $nextExec;
break;
default:

View File

@ -283,6 +283,18 @@ class TaskModel extends AdminModel
$data->execution_rules['exec-day'] = gmdate('d');
$data->execution_rules['exec-time'] = gmdate('H:i');
}
if ($data->next_execution) {
$data->next_execution = Factory::getDate($data->next_execution);
$data->next_execution->setTimezone(new \DateTimeZone($this->app->get('offset', 'UTC')));
$data->next_execution = $data->next_execution->toSql(true);
}
if ($data->last_execution) {
$data->last_execution = Factory::getDate($data->last_execution);
$data->last_execution->setTimezone(new \DateTimeZone($this->app->get('offset', 'UTC')));
$data->last_execution = $data->last_execution->toSql(true);
}
}
// Let plugins manipulate the data