diff options
author | sgiehl <stefan@piwik.org> | 2015-10-25 00:14:32 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-10-28 00:31:59 +0300 |
commit | 4c2da288d20341adebc953c1d0703c18fcb55487 (patch) | |
tree | 8c2a0e777426df08f12690446b36a839c454a6b6 /core/Date.php | |
parent | 7c258e2cdea17f50a9864493eb57f68a6aa85273 (diff) |
allow user to chosse between 12 and 24 hour time format
Diffstat (limited to 'core/Date.php')
-rw-r--r-- | core/Date.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/Date.php b/core/Date.php index bac8ce7db2..eac218eb9e 100644 --- a/core/Date.php +++ b/core/Date.php @@ -11,6 +11,7 @@ namespace Piwik; use Exception; use Piwik\Container\StaticContainer; +use Piwik\Plugins\LanguagesManager\Model as LanguagesManagerModel; /** * Utility class that wraps date/time related PHP functions. Using this class can @@ -627,6 +628,31 @@ class Date $template = $translator->translate($template); } + if (strpos($template, '{time}') !== false) { + + static $use12HourClock = null; + + if (is_null($use12HourClock)) { + + $model = new LanguagesManagerModel(); + + $use12HourClock = $model->uses12HourClock(Piwik::getCurrentUserLogin()); + } + + $timeFormat = 'Intl_Format_Time_24'; + + if ($use12HourClock) { + $timeFormat = 'Intl_Format_Time_12'; + + } + + $translator = StaticContainer::get('Piwik\Translation\Translator'); + $replacement = $translator->translate($timeFormat); + + $template = str_replace('{time}', $replacement, $template); + } + + $tokens = self::parseFormat($template); $out = ''; |