diff --git a/src/IDF/Form/IssueUpdate.php b/src/IDF/Form/IssueUpdate.php index 160f306..946f11b 100644 --- a/src/IDF/Form/IssueUpdate.php +++ b/src/IDF/Form/IssueUpdate.php @@ -103,10 +103,11 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate 'size' => 15, ), )); + $due_dtime = substr($this->issue->due_dtime, 0, 10); $this->fields['due_dtime'] = new IDF_Form_Field_Date( array('required' => false, 'label' => __('Due date'), - 'initial' => $this->issue->due_dtime, + 'initial' => $due_dtime, 'widget_attrs' => array('size' => 15,), )); diff --git a/src/IDF/Issue.php b/src/IDF/Issue.php index 0ec01ea..90ddb84 100644 --- a/src/IDF/Issue.php +++ b/src/IDF/Issue.php @@ -156,17 +156,16 @@ class IDF_Issue extends Pluf_Model IDF_Search::remove($this); } - function restore() { - $this->due_dtime = substr($this->due_dtime, 0, 10); - } - function preSave($create=false) { if ($this->id == '') { $this->creation_dtime = gmdate('Y-m-d H:i:s'); } - if($this->due_dtime) { - $this->due_dtime .= ' 23:59:59'; + if($this->due_dtime and !empty($this->due_dtime)) { + $datetime = $this->due_dtime . ' 23:59:59'; + if(date('Y-m-d', strtotime($datetime)) === $this->due_dtime) { + $this->due_dtime = $datetime; + } } $this->modif_dtime = gmdate('Y-m-d H:i:s'); }