aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2015-02-24 19:23:42 +0100
committerfilip <filip.komar@gmail.com>2015-02-24 19:23:42 +0100
commit7eb21c5a5fab11e060d81f104404d3817ebe09c9 (patch)
treecd8ba3529da7906a08128c0631bce433eb26d79b /lib
parent326d88ba3a718810a0aa7af74f172eb8b002c4ed (diff)
downloadwww-7eb21c5a5fab11e060d81f104404d3817ebe09c9.tar
www-7eb21c5a5fab11e060d81f104404d3817ebe09c9.tar.gz
www-7eb21c5a5fab11e060d81f104404d3817ebe09c9.tar.bz2
www-7eb21c5a5fab11e060d81f104404d3817ebe09c9.tar.xz
www-7eb21c5a5fab11e060d81f104404d3817ebe09c9.zip
news_date localisable on community page
Diffstat (limited to 'lib')
-rw-r--r--lib/news.php27
1 files changed, 6 insertions, 21 deletions
diff --git a/lib/news.php b/lib/news.php
index 397c18b52..7f8f09a4d 100644
--- a/lib/news.php
+++ b/lib/news.php
@@ -26,32 +26,17 @@ function html_news($locale = 'en', $count = 5)
}
/**
- * @param string $dt
+ * @param string $dt date in the form ISO 8601 (2015-02-24T15:42:00+01:00)
* @param string $locale
*
- * @return string
+ * @return string localised date
*/
function news_date($dt, $locale = 'en')
{
- $months = array(
- 'en' => array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
- 'fr' => array('jan', 'fév', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'sept', 'oct', 'nov', 'déc'),
- 'de' => array('Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez')
- );
- $formats = array(
- 'en' => 'M d Y',
- 'fr' => 'd M Y',
- 'de' => 'd. M Y',
- 'default' => 'Y-m-d'
- );
- $ft = array_key_exists($locale, $formats) ? $locale : 'default';
-
- $dts = strtotime($dt);
- $dt = date($formats[$ft], $dts);
- if (array_key_exists($locale, $months))
- $dt = str_replace($months['en'], $months[$locale], $dt);
-
- return $dt;
+ $eng_months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
+ $localised_months = array(_r('Jan'), _r('Feb'), _r('Mar'), _r('Apr'), _r('May'), _r('Jun'), _r('Jul'), _r('Aug'), _r('Sep'), _r('Oct'), _r('Nov'), _r('Dec'));
+
+ return str_replace($eng_months, $localised_months, date(_r('M d Y'), strtotime($dt)));
}
/**