aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2015-05-01 12:56:14 +0200
committerfilip <filip.komar@gmail.com>2015-05-01 12:56:14 +0200
commitc2158bebcc570b4f1a573122a546310268434e9e (patch)
treee5bd58407e02cd2f1103aa725e933748de3b5b05 /lib
parent6f42812eb739dfbee90f61bfac0608aebd7e57cb (diff)
downloadwww-c2158bebcc570b4f1a573122a546310268434e9e.tar
www-c2158bebcc570b4f1a573122a546310268434e9e.tar.gz
www-c2158bebcc570b4f1a573122a546310268434e9e.tar.bz2
www-c2158bebcc570b4f1a573122a546310268434e9e.tar.xz
www-c2158bebcc570b4f1a573122a546310268434e9e.zip
added fallback for invalid date format localisation
Diffstat (limited to 'lib')
-rw-r--r--lib/news.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/news.php b/lib/news.php
index 906f12f55..90effbb22 100644
--- a/lib/news.php
+++ b/lib/news.php
@@ -36,7 +36,14 @@ function news_date($dt, $locale = 'en')
$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)));
+ $date_format = _r('M d Y');
+ if ((strpbrk($date_format, 'dj') == false) // check valid day formats
+ || (strpbrk($date_format, 'M') == false) // check valid month formats (all are 'FmMn' but we replace them in 3 letter form)
+ || (strpbrk($date_format, 'oYy') == false)) // check valid year formats
+ {
+ $date_format = 'M d Y'; // fallback for invalid date format localisation
+ }
+ return str_replace($eng_months, $localised_months, date($date_format, strtotime($dt)));
}
/**