diff options
Diffstat (limited to 'lib/news.php')
-rw-r--r-- | lib/news.php | 9 |
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))); } /** |