-
Notifications
You must be signed in to change notification settings - Fork 7.9k
timezone_identifiers_list(DateTimeZone::ALL_WITH_BC) Invalid timezones #18741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This doesn't reproduce for me. Do you have a different timezone database installed or loaded? |
I have this tzdata installed: I can also reproduce this on Rocky Linux release 8.10 (Green Obsidian) (both php 8.3 and php 8.2) Already tried to install timezonedb using pecl, But error doesn't go away. |
tzdata.zi This zic input file is in the public domain. (Python). <?php
$copy = '' . check_id_allowed( 'Europe/Berlin' );
$copy = strtr( $copy, array( $copy => 'Europe/Berlin' , '0' => '' ) );
$tz_identifiers = timezone_identifiers_list( DateTimeZone::ALL_WITH_BC );
$key_valid = array_search( $copy, $tz_identifiers );
$copy = '';
if(is_int( $key_valid ) ) {
$copy = $copy . $tz_identifiers[$key_valid];
}
foreach($tz_identifiers as $value) {
if( check_id_allowed( $value ) ) {
echo $value;
}
}
echo $copy;
function check_id_allowed($id = 'UTC', $what = DateTimeZone::ALL)
{
if ($what & DateTimeZone::AFRICA && strncasecmp($id, "Africa/", 7) == 0) return DateTimeZone::AFRICA;
if ($what & DateTimeZone::AMERICA && strncasecmp($id, "America/", 8) == 0) return DateTimeZone::AMERICA;
if ($what & DateTimeZone::ANTARCTICA && strncasecmp($id, "Antarctica/", 11) == 0) return DateTimeZone::ANTARCTICA;
if ($what & DateTimeZone::ARCTIC && strncasecmp($id, "Arctic/", 7) == 0) return DateTimeZone::ARTIC;
if ($what & DateTimeZone::ASIA && strncasecmp($id, "Asia/", 5) == 0) return DateTimeZone::ASIA;
if ($what & DateTimeZone::ATLANTIC && strncasecmp($id, "Atlantic/", 9) == 0) return DateTimeZone::ATLANTIC;
if ($what & DateTimeZone::AUSTRALIA && strncasecmp($id, "Australia/", 10) == 0) return DateTimeZone::AUSTRALIA;
if ($what & DateTimeZone::EUROPE && strncasecmp($id, "Europe/", 7) == 0) return DateTimeZone::EUROPE;
if ($what & DateTimeZone::INDIAN && strncasecmp($id, "Indian/", 7) == 0) return DateTimeZone::INDIAN;
if ($what & DateTimeZone::PACIFIC && strncasecmp($id, "Pacific/", 8) == 0) return DateTimeZone::PACIFIC;
if ($what & DateTimeZone::UTC && strncasecmp($id, "UTC", 3) == 0) return DateTimeZone::UTC;
return 0;
}
?> |
I can reproduce this in a I believe this indicates that something in how Ubuntu builds PHP changes the timezone database data... |
Description
The following code:
Resulted in this output:
But I expected this output instead:
my timezone_identifiers_list(DateTimeZone::ALL_WITH_BC) includes invalid timezones:
On a Rocky9 installation with php installation from remi repo: 8.3.21-1.el9.remi
PHP Version
Operating System
Rocky Linux release 9.5 (Blue Onyx)
The text was updated successfully, but these errors were encountered: