Display local date format in date picker
This commit is contained in:
@@ -14,6 +14,7 @@ class DateParser extends Base
|
||||
{
|
||||
const DATE_FORMAT = 'm/d/Y';
|
||||
const DATE_TIME_FORMAT = 'm/d/Y H:i';
|
||||
const TIME_FORMAT = 'H:i';
|
||||
|
||||
/**
|
||||
* Get date format from settings
|
||||
@@ -37,6 +38,17 @@ class DateParser extends Base
|
||||
return $this->configModel->get('application_datetime_format', DateParser::DATE_TIME_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time format from settings
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getUserTimeFormat()
|
||||
{
|
||||
return $this->configModel->get('application_time_format', DateParser::TIME_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of time formats
|
||||
*
|
||||
|
||||
@@ -93,6 +93,39 @@ class AppHelper extends Base
|
||||
return $this->languageModel->getJsLanguageCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get date format for Jquery DatePicker
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getJsDateFormat()
|
||||
{
|
||||
$format = $this->dateParser->getUserDateFormat();
|
||||
$format = str_replace('m', 'mm', $format);
|
||||
$format = str_replace('Y', 'yy', $format);
|
||||
$format = str_replace('d', 'dd', $format);
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time format for Jquery Plugin DateTimePicker
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getJsTimeFormat()
|
||||
{
|
||||
$format = $this->dateParser->getUserTimeFormat();
|
||||
$format = str_replace('H', 'HH', $format);
|
||||
$format = str_replace('i', 'mm', $format);
|
||||
$format = str_replace('g', 'h', $format);
|
||||
$format = str_replace('a', 'tt', $format);
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current timezone
|
||||
*
|
||||
|
||||
@@ -48,7 +48,10 @@
|
||||
data-login-url="<?= $this->url->href('AuthController', 'login') ?>"
|
||||
data-keyboard-shortcut-url="<?= $this->url->href('DocumentationController', 'shortcuts') ?>"
|
||||
data-timezone="<?= $this->app->getTimezone() ?>"
|
||||
data-js-lang="<?= $this->app->jsLang() ?>">
|
||||
data-js-lang="<?= $this->app->jsLang() ?>"
|
||||
data-js-date-format="<?= $this->app->getJsDateFormat() ?>"
|
||||
data-js-time-format="<?= $this->app->getJsTimeFormat() ?>"
|
||||
>
|
||||
|
||||
<?php if (isset($no_layout) && $no_layout): ?>
|
||||
<?= $content_for_layout ?>
|
||||
|
||||
Reference in New Issue
Block a user