From d375eea361684a1e90a5e664e44c1fbdda8cf5a3 Mon Sep 17 00:00:00 2001 From: Mitchell Bennett Date: Mon, 13 Feb 2017 11:04:18 +1300 Subject: [PATCH] Solved issue #114 where a job's StartAfter date was always being saved in American format irrespective of the user's chosen DateFormat setting. --- code/controllers/QueuedJobsAdmin.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/code/controllers/QueuedJobsAdmin.php b/code/controllers/QueuedJobsAdmin.php index 937ff18f..dba636a8 100644 --- a/code/controllers/QueuedJobsAdmin.php +++ b/code/controllers/QueuedJobsAdmin.php @@ -38,6 +38,12 @@ class QueuedJobsAdmin extends ModelAdmin { 'EditForm' ); + /** + * European date format + * @var string + */ + private static $date_format_european = 'dd/MM/yyyy'; + /** * @var QueuedJobService */ @@ -134,6 +140,12 @@ public function createjob($data, Form $form) { $js = $form->Fields()->dataFieldByName('JobStart'); $time = $js->Value(); + // If the user has select the European date format as their setting then replace '/' with '-' in the date string so PHP + // treats the date as this format. + if (Member::currentUser()->DateFormat == self::$date_format_european) { + $time = str_replace('/', '-', $time); + } + if ($jobType && class_exists($jobType)) { $jobClass = new ReflectionClass($jobType); $job = $jobClass->newInstanceArgs($params);