Skip to content

Commit

Permalink
[4.4] Determine the next task run date with the timezone of the site (#…
Browse files Browse the repository at this point in the history
…43259)

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

* cs

---------
  • Loading branch information
laoneo committed Apr 26, 2024
1 parent 079047c commit d1bef33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -104,7 +104,8 @@ public function nextExec(bool $string = true, bool $basisNow = false)
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:
Expand Down
12 changes: 12 additions & 0 deletions administrator/components/com_scheduler/src/Model/TaskModel.php
Expand Up @@ -283,6 +283,18 @@ protected function loadFormData()
$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
Expand Down

0 comments on commit d1bef33

Please sign in to comment.