From 8d4dfb5d915aba641f809bdccab3003bd35a2db6 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 12 Mar 2012 13:02:11 +1300 Subject: [PATCH] Handle HTTP date formatting for non-english locales (force English names). --- htdocs/always.php | 20 +++++++++++++++++++- inc/always.php.in | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/htdocs/always.php b/htdocs/always.php index 1768e974..b067839b 100644 --- a/htdocs/always.php +++ b/htdocs/always.php @@ -334,8 +334,26 @@ function DeconstructURL( $url, $force_script = false ) { * @param string $isodate The date to convert */ function ISODateToHTTPDate( $isodate ) { + // It is necessary to use English for this, explicitly. See Debian BTS Bug#661985 for more info. + $month = gmstrftime('%m', strtotime($isodate)); + switch( intval($month) ) { + case 1: $month = 'January'; break; + case 2: $month = 'February'; break; + case 3: $month = 'March'; break; + case 4: $month = 'April'; break; + case 5: $month = 'May'; break; + case 6: $month = 'June'; break; + case 7: $month = 'July'; break; + case 8: $month = 'August'; break; + case 9: $month = 'September'; break; + case 10: $month = 'October'; break; + case 11: $month = 'November'; break; + case 12: $month = 'December'; break; + default: + throw new Exception('Invalid month '.$month); + } // Use strtotime since strptime is not available on Windows platform. - return( gmstrftime('%a, %d %b %Y %H:%M:%S GMT', strtotime($isodate)) ); + return( gmstrftime('%a, '.$month.' %b %Y %H:%M:%S GMT', strtotime($isodate)) ); } /** diff --git a/inc/always.php.in b/inc/always.php.in index b1c32d23..f41104a6 100644 --- a/inc/always.php.in +++ b/inc/always.php.in @@ -334,8 +334,26 @@ function DeconstructURL( $url, $force_script = false ) { * @param string $isodate The date to convert */ function ISODateToHTTPDate( $isodate ) { + // It is necessary to use English for this, explicitly. See Debian BTS Bug#661985 for more info. + $month = gmstrftime('%m', strtotime($isodate)); + switch( intval($month) ) { + case 1: $month = 'January'; break; + case 2: $month = 'February'; break; + case 3: $month = 'March'; break; + case 4: $month = 'April'; break; + case 5: $month = 'May'; break; + case 6: $month = 'June'; break; + case 7: $month = 'July'; break; + case 8: $month = 'August'; break; + case 9: $month = 'September'; break; + case 10: $month = 'October'; break; + case 11: $month = 'November'; break; + case 12: $month = 'December'; break; + default: + throw new Exception('Invalid month '.$month); + } // Use strtotime since strptime is not available on Windows platform. - return( gmstrftime('%a, %d %b %Y %H:%M:%S GMT', strtotime($isodate)) ); + return( gmstrftime('%a, '.$month.' %b %Y %H:%M:%S GMT', strtotime($isodate)) ); } /**