From 3bebc9a35fba318c3543dca0c3387569d8893226 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sat, 25 Jan 2014 20:22:54 +0100 Subject: [PATCH] add IntlDateFormatter for formatting locale-dependent date and time --- app/Controller.inc | 14 +++++++++ app/Utils.inc | 8 ----- configs/AppConfig.inc | 3 +- locale/de_DE/LC_MESSAGES/The Legend of Z.mo | Bin 1407 -> 1544 bytes locale/de_DE/LC_MESSAGES/The Legend of Z.po | 32 +++++++++++++++++--- views/html/seminaries/index.tpl | 2 +- views/html/seminaries/seminary.tpl | 2 +- views/html/users/index.tpl | 2 +- views/html/users/user.tpl | 2 +- 9 files changed, 47 insertions(+), 18 deletions(-) diff --git a/app/Controller.inc b/app/Controller.inc index 24301a88..5594ac31 100644 --- a/app/Controller.inc +++ b/app/Controller.inc @@ -82,6 +82,20 @@ // Create linker $this->linker = new \nre\core\Linker($this->request); + // Create date and time formatter + $this->set('dateFormatter', new \IntlDateFormatter( + \nre\core\Config::getDefault('locale'), + \IntlDateFormatter::MEDIUM, + \IntlDateFormatter::NONE, + NULL + )); + $this->set('timeFormatter', new \IntlDateFormatter( + \nre\core\Config::getDefault('locale'), + \IntlDateFormatter::NONE, + \IntlDateFormatter::SHORT, + NULL + )); + // Set userdata $this->set('loggedUser', static::$user); } diff --git a/app/Utils.inc b/app/Utils.inc index 3ef93670..1e3527c1 100644 --- a/app/Utils.inc +++ b/app/Utils.inc @@ -19,14 +19,6 @@ */ class Utils { - - /** - * Format for printing the date - * - * @var string - */ - const DATEFORMAT = 'm.d.Y'; - } ?> diff --git a/configs/AppConfig.inc b/configs/AppConfig.inc index c4ef5929..12624ab0 100644 --- a/configs/AppConfig.inc +++ b/configs/AppConfig.inc @@ -47,7 +47,8 @@ 'toplevel-error' => 'fault', 'intermediate' => 'introduction', 'intermediate-error' => 'error', - 'language' => 'de_DE.utf8' + 'language' => 'de_DE.utf8', + 'locale' => 'de-DE' ); diff --git a/locale/de_DE/LC_MESSAGES/The Legend of Z.mo b/locale/de_DE/LC_MESSAGES/The Legend of Z.mo index a8dd7d2c500d170581bcd7b63409bb2c2e4438c8..cb455ec186be0d5ee691003275f56b08f9b65462 100644 GIT binary patch delta 654 zcmey*)xlGLPl#nI0|NttI0FNN327#J8XvoJ6SGB7Z_VS#w)9}CD~^$ZL` ztPqWotPr1Ru|j-g#tKrvz+l4)aiB9R0|Ore1A`wc#0RlZb!n^&3|0&b3^`E#a#lzP ztc9xE#R>_j!%+GxD+7Zl0|Uc#kbFG@1H)TZh|9jQGBAKbotFXP5Rhe%NPxH)qzT3c z(d-Ni3}Orn3_=VH3``&a1_lOZ28g3UTu_v)WMB|rU|{&m$iTqEz`(%A1QC~JVqjonU|>*WVqoB4 zU|`UI(uPb73|tHh3|34G3r@YA{K}THnTt+xF0NE&%kh$ zg@J*Ofq~%+3&f?jp$eX`Ffdp#FfhDgf%r_76(VoM3JC#gDDBG1z#z)Nz~B#+Pi2Kz zn8(V%01ZTN2!X

- + format(new \DateTime($seminary['created'])))?>
diff --git a/views/html/seminaries/seminary.tpl b/views/html/seminaries/seminary.tpl index 094fbf3b..3c5f1aba 100644 --- a/views/html/seminaries/seminary.tpl +++ b/views/html/seminaries/seminary.tpl @@ -1,5 +1,5 @@

- + format(new \DateTime($seminary['created'])))?>

diff --git a/views/html/users/index.tpl b/views/html/users/index.tpl index 9a5b525e..5d2883af 100644 --- a/views/html/users/index.tpl +++ b/views/html/users/index.tpl @@ -7,7 +7,7 @@
  • - + format(new \DateTime($user['created'])))?>
  • diff --git a/views/html/users/user.tpl b/views/html/users/user.tpl index 1e8466b5..e3a037af 100644 --- a/views/html/users/user.tpl +++ b/views/html/users/user.tpl @@ -4,5 +4,5 @@
  • - + format(new \DateTime($user['created'])))?>