Simplify date and time configuration to avoid potential validation issues
This commit is contained in:
@@ -7,6 +7,8 @@ New features:
|
|||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
* Simplify date and time configuration to avoid potential validation issues
|
||||||
|
|
||||||
Regressions:
|
Regressions:
|
||||||
|
|
||||||
* Stay on the same page when a task is closed
|
* Stay on the same page when a task is closed
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ class ConfigController extends BaseController
|
|||||||
'languages' => $this->languageModel->getLanguages(),
|
'languages' => $this->languageModel->getLanguages(),
|
||||||
'timezones' => $this->timezoneModel->getTimezones(),
|
'timezones' => $this->timezoneModel->getTimezones(),
|
||||||
'date_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateFormats()),
|
'date_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateFormats()),
|
||||||
'datetime_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateTimeFormats()),
|
|
||||||
'time_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getTimeFormats()),
|
'time_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getTimeFormats()),
|
||||||
'title' => t('Settings').' > '.t('Application settings'),
|
'title' => t('Settings').' > '.t('Application settings'),
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use DateTime;
|
|||||||
class DateParser extends Base
|
class DateParser extends Base
|
||||||
{
|
{
|
||||||
const DATE_FORMAT = 'm/d/Y';
|
const DATE_FORMAT = 'm/d/Y';
|
||||||
const DATE_TIME_FORMAT = 'm/d/Y H:i';
|
|
||||||
const TIME_FORMAT = 'H:i';
|
const TIME_FORMAT = 'H:i';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +34,7 @@ class DateParser extends Base
|
|||||||
*/
|
*/
|
||||||
public function getUserDateTimeFormat()
|
public function getUserDateTimeFormat()
|
||||||
{
|
{
|
||||||
return $this->configModel->get('application_datetime_format', DateParser::DATE_TIME_FORMAT);
|
return $this->getUserDateFormat().' '.$this->getUserTimeFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class DateHelper extends Base
|
|||||||
*/
|
*/
|
||||||
public function datetime($value)
|
public function datetime($value)
|
||||||
{
|
{
|
||||||
return date($this->configModel->get('application_datetime_format', 'm/d/Y H:i'), $value);
|
return date($this->dateParser->getUserDateTimeFormat(), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,9 +23,6 @@
|
|||||||
<?= $this->form->select('application_date_format', $date_formats, $values, $errors) ?>
|
<?= $this->form->select('application_date_format', $date_formats, $values, $errors) ?>
|
||||||
<p class="form-help"><?= t('ISO format is always accepted, example: "%s" and "%s"', date('Y-m-d'), date('Y_m_d')) ?></p>
|
<p class="form-help"><?= t('ISO format is always accepted, example: "%s" and "%s"', date('Y-m-d'), date('Y_m_d')) ?></p>
|
||||||
|
|
||||||
<?= $this->form->label(t('Date and time format'), 'application_datetime_format') ?>
|
|
||||||
<?= $this->form->select('application_datetime_format', $datetime_formats, $values, $errors) ?>
|
|
||||||
|
|
||||||
<?= $this->form->label(t('Time format'), 'application_time_format') ?>
|
<?= $this->form->label(t('Time format'), 'application_time_format') ?>
|
||||||
<?= $this->form->select('application_time_format', $time_formats, $values, $errors) ?>
|
<?= $this->form->select('application_time_format', $time_formats, $values, $errors) ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class DateParserTest extends Base
|
|||||||
$dates = $dateParser->getDateTimeFormats(true);
|
$dates = $dateParser->getDateTimeFormats(true);
|
||||||
$this->assertEquals('m/d/Y H:i', $dates[0]);
|
$this->assertEquals('m/d/Y H:i', $dates[0]);
|
||||||
|
|
||||||
$this->container['configModel']->save(array('application_datetime_format' => 'd/m/Y g:i a'));
|
$this->container['configModel']->save(array('application_date_format' => 'd/m/Y', 'application_time_format' => 'g:i a'));
|
||||||
$this->container['memoryCache']->flush();
|
$this->container['memoryCache']->flush();
|
||||||
|
|
||||||
$dates = $dateParser->getDateTimeFormats();
|
$dates = $dateParser->getDateTimeFormats();
|
||||||
@@ -121,7 +121,7 @@ class DateParserTest extends Base
|
|||||||
{
|
{
|
||||||
$this->container['configModel']->save(array(
|
$this->container['configModel']->save(array(
|
||||||
'application_date_format' => 'd/m/Y',
|
'application_date_format' => 'd/m/Y',
|
||||||
'application_datetime_format' => 'd/m/Y g:i a',
|
'application_time_format' => 'g:i a',
|
||||||
));
|
));
|
||||||
|
|
||||||
$dateParser = new DateParser($this->container);
|
$dateParser = new DateParser($this->container);
|
||||||
|
|||||||
Reference in New Issue
Block a user