summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Core/DateParser.php12
-rw-r--r--app/Helper/AppHelper.php33
-rw-r--r--app/Template/layout.php5
3 files changed, 49 insertions, 1 deletions
diff --git a/app/Core/DateParser.php b/app/Core/DateParser.php
index bdab7998..a7b10a7a 100644
--- a/app/Core/DateParser.php
+++ b/app/Core/DateParser.php
@@ -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
@@ -38,6 +39,17 @@ class DateParser extends Base
}
/**
+ * 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
*
* @access public
diff --git a/app/Helper/AppHelper.php b/app/Helper/AppHelper.php
index b738f85c..09f280cb 100644
--- a/app/Helper/AppHelper.php
+++ b/app/Helper/AppHelper.php
@@ -94,6 +94,39 @@ class AppHelper extends Base
}
/**
+ * 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
*
* @access public
diff --git a/app/Template/layout.php b/app/Template/layout.php
index ebce6ffa..411237cb 100644
--- a/app/Template/layout.php
+++ b/app/Template/layout.php
@@ -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 ?>