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 zcmYk3J4gdT5QaCo%hM!ke1ne@6hRR}K*eAq0YL<9#3E{uVwJ!pMIHpJU?*aC*lKBI zWv5_cDWafamUEG*S;l8ZRp?6tx%P>g1-(*c4G6}Qbzyv&ja^ZdRfO>Z0 zI+TlEUA{pP_UXocqbVQ?PZ2*1yV<`smFkC&uoJ#R`R^P0RZXcl*+lsOl*%Td2$*G% zgbPpvreO@OLaAUI@~It$6tvy=3`z&ip`5#f(y1Glcd&=}MfS=hn=~HQIK@d>j63o{Q8k!JA11 delta 531 zcmXxhD@X)E9LMpweR$`2o_Z<>-hmecqqo7wnhaYkhSPR+gGB@%bpaCta_jPI93{WS zOE&G}40$IoW&#gU-yfsaxj-H83ROT4wa;BXo*8pbr^<^5)Jb362Ok)df1)azXO_kz z)D5gT6PzaBbmJ*%!(HTjc_>#D2jmCS8l^T5*3VC@s{TV)&iwqh=$#JWtK&jfsA?!a z4;7&5YcyN;I=1U=*k>=X4S&5D&9#=|XvL;})Ad(-XZ~`*z65)AD{R}Fa68;jcMi-S Di

- + 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'])))?>