Fix wrong datetime formatting when task form shows validation errors
This commit is contained in:
@@ -12,6 +12,10 @@ Regressions:
|
|||||||
* Stay on the same page when a task is closed
|
* Stay on the same page when a task is closed
|
||||||
* Wrong URL in modal to move task to another project
|
* Wrong URL in modal to move task to another project
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* Fix wrong datetime formatting when task form shows validation errors
|
||||||
|
|
||||||
Version 1.0.37 (Jan 14, 2017)
|
Version 1.0.37 (Jan 14, 2017)
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -292,11 +292,9 @@ class DateParser extends Base
|
|||||||
{
|
{
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if (! empty($values[$field])) {
|
if (! empty($values[$field])) {
|
||||||
if (! ctype_digit($values[$field])) {
|
if (ctype_digit($values[$field])) {
|
||||||
$values[$field] = strtotime($values[$field]);
|
$values[$field] = date($format, $values[$field]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$values[$field] = date($format, $values[$field]);
|
|
||||||
} else {
|
} else {
|
||||||
$values[$field] = '';
|
$values[$field] = '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class TaskValidator extends BaseValidator
|
|||||||
new Validators\MaxLength('title', t('The maximum length is %d characters', 200), 200),
|
new Validators\MaxLength('title', t('The maximum length is %d characters', 200), 200),
|
||||||
new Validators\MaxLength('reference', t('The maximum length is %d characters', 50), 50),
|
new Validators\MaxLength('reference', t('The maximum length is %d characters', 50), 50),
|
||||||
new Validators\Date('date_due', t('Invalid date'), $this->dateParser->getParserFormats()),
|
new Validators\Date('date_due', t('Invalid date'), $this->dateParser->getParserFormats()),
|
||||||
new Validators\Date('date_started', t('Invalid date'), $this->dateParser->getParserFormats()),
|
new Validators\Date('date_started', t('Invalid date'), array($this->dateParser->getUserDateTimeFormat())),
|
||||||
new Validators\Numeric('time_spent', t('This value must be numeric')),
|
new Validators\Numeric('time_spent', t('This value must be numeric')),
|
||||||
new Validators\Numeric('time_estimated', t('This value must be numeric')),
|
new Validators\Numeric('time_estimated', t('This value must be numeric')),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -204,9 +204,6 @@ class DateParserTest extends Base
|
|||||||
|
|
||||||
$this->assertEquals(array('date' => '06/02/2016'), $dateParser->format($values, array('date'), 'd/m/Y'));
|
$this->assertEquals(array('date' => '06/02/2016'), $dateParser->format($values, array('date'), 'd/m/Y'));
|
||||||
$this->assertEquals(array('date' => '02/06/2016 7:30 pm'), $dateParser->format($values, array('date'), 'm/d/Y g:i a'));
|
$this->assertEquals(array('date' => '02/06/2016 7:30 pm'), $dateParser->format($values, array('date'), 'm/d/Y g:i a'));
|
||||||
|
|
||||||
$values['date'] = '2016-02-06';
|
|
||||||
$this->assertEquals(array('date' => '06/02/2016'), $dateParser->format($values, array('date'), 'd/m/Y'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConvert()
|
public function testConvert()
|
||||||
|
|||||||
Reference in New Issue
Block a user