Skip to content

Commit

Permalink
Solved issue #114 where a job's StartAfter date was always being save…
Browse files Browse the repository at this point in the history
…d in American format irrespective of the user's chosen DateFormat setting.
  • Loading branch information
Mitchell Bennett committed Feb 12, 2017
1 parent f17a1b9 commit d375eea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions code/controllers/QueuedJobsAdmin.php
Expand Up @@ -38,6 +38,12 @@ class QueuedJobsAdmin extends ModelAdmin {
'EditForm'
);

/**
* European date format
* @var string
*/
private static $date_format_european = 'dd/MM/yyyy';

/**
* @var QueuedJobService
*/
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d375eea

Please sign in to comment.