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

This commit is contained in:
Simon Holywell 2012-04-13 14:07:18 +01:00
parent cf2f9d419e
commit 3e78376be3
8 changed files with 50 additions and 22 deletions

View File

@ -0,0 +1,36 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
class IDF_Form_Field_Date extends Pluf_Form_Field_Date
{
public function clean($value) {
try {
return parent::clean($value);
} catch (Pluf_Form_Invalid $e) {
if(false === $this->required and empty($value)) {
return null;
}
throw $e;
}
}
}

View File

@ -112,7 +112,7 @@ class IDF_Form_IssueCreate extends Pluf_Form
'size' => 15, 'size' => 15,
), ),
)); ));
$this->fields['due_dtime'] = new IDF_Form_Field_Datetime( $this->fields['due_dtime'] = new IDF_Form_Field_Date(
array('required' => false, array('required' => false,
'label' => __('Due date'), 'label' => __('Due date'),
'initial' => '', 'initial' => '',

View File

@ -103,7 +103,7 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
'size' => 15, 'size' => 15,
), ),
)); ));
$this->fields['due_dtime'] = new IDF_Form_Field_Datetime( $this->fields['due_dtime'] = new IDF_Form_Field_Date(
array('required' => false, array('required' => false,
'label' => __('Due date'), 'label' => __('Due date'),
'initial' => $this->issue->due_dtime, 'initial' => $this->issue->due_dtime,

View File

@ -156,11 +156,18 @@ class IDF_Issue extends Pluf_Model
IDF_Search::remove($this); IDF_Search::remove($this);
} }
function restore() {
$this->due_dtime = substr($this->due_dtime, 0, 10);
}
function preSave($create=false) function preSave($create=false)
{ {
if ($this->id == '') { if ($this->id == '') {
$this->creation_dtime = gmdate('Y-m-d H:i:s'); $this->creation_dtime = gmdate('Y-m-d H:i:s');
} }
if($this->due_dtime) {
$this->due_dtime .= ' 23:59:59';
}
$this->modif_dtime = gmdate('Y-m-d H:i:s'); $this->modif_dtime = gmdate('Y-m-d H:i:s');
} }

View File

@ -484,7 +484,6 @@ class IDF_Views_Issue
'date_1_week' => date('Y-m-d', strtotime('+1 week')), 'date_1_week' => date('Y-m-d', strtotime('+1 week')),
'date_two_weeks' => date('Y-m-d', strtotime('+2 week')), 'date_two_weeks' => date('Y-m-d', strtotime('+2 week')),
'date_one_month' => date('Y-m-d', strtotime('+1 month')), 'date_one_month' => date('Y-m-d', strtotime('+1 month')),
'default_time' => Pluf::f('issue_default_due_date_time'),
), ),
self::autoCompleteArrays($prj) self::autoCompleteArrays($prj)
); );
@ -731,7 +730,6 @@ class IDF_Views_Issue
'date_1_week' => date('Y-m-d', strtotime('+1 week')), 'date_1_week' => date('Y-m-d', strtotime('+1 week')),
'date_two_weeks' => date('Y-m-d', strtotime('+2 week')), 'date_two_weeks' => date('Y-m-d', strtotime('+2 week')),
'date_one_month' => date('Y-m-d', strtotime('+1 month')), 'date_one_month' => date('Y-m-d', strtotime('+1 month')),
'default_time' => Pluf::f('issue_default_due_date_time'),
), ),
$arrays), $arrays),
$request); $request);

View File

@ -544,9 +544,4 @@ $cfg['activity_section_weights'] = array(
# high enough to show a proper activity index for those projects as well. # high enough to show a proper activity index for those projects as well.
$cfg['activity_lookback'] = 7; $cfg['activity_lookback'] = 7;
# Configure the default time that should be used when setting an issue due date
# via the quick (COB, EOW, etc) menu or via the date picker
$cfg['issue_default_due_date_time'] = '17:30';
return $cfg; return $cfg;

View File

@ -129,7 +129,6 @@
{/block} {/block}
{block javascript} {block javascript}
<script type="text/javascript"> <script type="text/javascript">
var default_time = '{$default_time}';
document.getElementById('id_summary').focus();{literal} document.getElementById('id_summary').focus();{literal}
$(document).ready(function(){ $(document).ready(function(){
$("#id_due_dtime").datepicker({ $("#id_due_dtime").datepicker({
@ -137,10 +136,7 @@ $(document).ready(function(){
changeMonth: true, changeMonth: true,
yearRange: '-0:+5', yearRange: '-0:+5',
constrainInput: false, constrainInput: false,
dateFormat: 'yy-mm-dd', dateFormat: 'yy-mm-dd'
onSelect: function(dateText, inst) {
this.value = dateText + ' ' + default_time;
}
}); });
$('#due_dtime_wrapper').mouseover(function(){ $('#due_dtime_wrapper').mouseover(function(){
$('#due_dtime_more_shortcuts').show(); $('#due_dtime_more_shortcuts').show();

View File

@ -233,7 +233,6 @@
{/block} {/block}
{block javascript}{if $form}{include 'idf/issues/js-autocomplete.html'} {block javascript}{if $form}{include 'idf/issues/js-autocomplete.html'}
<script type="text/javascript"> <script type="text/javascript">
var default_time = '{$default_time}';
{literal} {literal}
$(document).ready(function(){ $(document).ready(function(){
$("#id_due_dtime").datepicker({ $("#id_due_dtime").datepicker({
@ -241,10 +240,7 @@ $(document).ready(function(){
changeMonth: true, changeMonth: true,
yearRange: '-0:+5', yearRange: '-0:+5',
constrainInput: false, constrainInput: false,
dateFormat: 'yy-mm-dd', dateFormat: 'yy-mm-dd'
onSelect: function(dateText, inst) {
this.value = dateText + ' ' + default_time;
}
}); });
$('#due_dtime_wrapper').mouseover(function(){ $('#due_dtime_wrapper').mouseover(function(){
$('#due_dtime_more_shortcuts').show(); $('#due_dtime_more_shortcuts').show();