1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-02 17:04:58 +02:00

Merge pull request #3626 from SimSync/fix_3625

Issue #3625: 'Z' and 'z' formats excluded on windows systems
This commit is contained in:
Cameron 2019-01-17 11:29:21 -08:00 committed by GitHub
commit 4e5dacf4d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -976,7 +976,7 @@ class e_date
'W' => 'A numeric representation of the week of the year, starting with the first Monday as the first week', 'W' => 'A numeric representation of the week of the year, starting with the first Monday as the first week',
'X' => 'Preferred time representation based on locale, without the date', 'X' => 'Preferred time representation based on locale, without the date',
'Y' => 'Four digit representation for the year', 'Y' => 'Four digit representation for the year',
'Z' => 'The time zone offset/abbreviation option NOT given by %z (depends on operating system)', //'Z' => 'The time zone offset/abbreviation option NOT given by %z (depends on operating system)',
'a' => 'An abbreviated textual representation of the day', 'a' => 'An abbreviated textual representation of the day',
'b' => 'Abbreviated month name, based on the locale', 'b' => 'Abbreviated month name, based on the locale',
'c' => 'Preferred date and time stamp based on local', 'c' => 'Preferred date and time stamp based on local',
@ -1002,9 +1002,16 @@ class e_date
'w' => 'Numeric representation of the day of the week', 'w' => 'Numeric representation of the day of the week',
'x' => 'Preferred date representation based on locale, without the time', 'x' => 'Preferred date representation based on locale, without the time',
'y' => 'Two digit representation of the year', 'y' => 'Two digit representation of the year',
'z' => 'Either the time zone offset from UTC or the abbreviation (depends on operating system)', //'z' => 'Either the time zone offset from UTC or the abbreviation (depends on operating system)',
'%' => 'A literal percentage character ("%")', '%' => 'A literal percentage character ("%")',
); );
if (stripos(PHP_OS, 'WIN') === false)
{
// This formats are not avaiilable on windows and will make the script fail on use.
$strftimeFormats['Z'] = 'The time zone offset/abbreviation option NOT given by %z (depends on operating system)';
$strftimeFormats['z'] = 'Either the time zone offset from UTC or the abbreviation (depends on operating system)';
}
// Results. // Results.
$strftimeValues = array(); $strftimeValues = array();
@ -1012,7 +1019,9 @@ class e_date
// Evaluate the formats whilst suppressing any errors. // Evaluate the formats whilst suppressing any errors.
foreach($strftimeFormats as $format => $description) foreach($strftimeFormats as $format => $description)
{ {
if (False !== ($value = @strftime("%{$format}"))) //if (False !== ($value = @strftime("%{$format}")))
$value = @strftime("%{$format}");
if (False !== $value)
{ {
$strftimeValues[$format] = $value; $strftimeValues[$format] = $value;
} }