Issue #13: Due time handling (local time / UTC)

- Move time strip into the formInit method and out of the model
- Improve the validation of the issue due date on the preSave method of the model
This commit is contained in:
Simon Holywell 2012-04-19 21:20:51 +01:00
parent 11b3811e17
commit 6996e1185f
2 changed files with 7 additions and 7 deletions

View File

@ -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,),
));

View File

@ -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');
}