Handle HTTP date formatting for non-english locales (force English names).

This commit is contained in:
Andrew McMillan 2012-03-12 13:02:11 +13:00
parent a6d6dfc8b8
commit 8d4dfb5d91
2 changed files with 38 additions and 2 deletions

View File

@ -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)) );
}
/**

View File

@ -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)) );
}
/**