概要
引数
実装
function availableTimezones($addBlank = false)
{
global $_DATE_TIMEZONE_DATA;
$_aTimezoneBcData = array(
'Brazil/Acre', 'Brazil/DeNoronha', 'Brazil/East', 'Brazil/West', 'Canada/Atlantic',
'Canada/Central', 'Canada/East-Saskatchewan', 'Canada/Eastern', 'Canada/Mountain',
'Canada/Newfoundland', 'Canada/Pacific', 'Canada/Saskatchewan', 'Canada/Yukon',
'CET', 'Chile/Continental', 'Chile/EasterIsland', 'CST6CDT', 'Cuba', 'EET',
'Egypt', 'Eire', 'EST', 'EST5EDT', 'Etc/GMT', 'Etc/GMT+0', 'Etc/GMT+1', 'Etc/GMT+10',
'Etc/GMT+11', 'Etc/GMT+12', 'Etc/GMT+2', 'Etc/GMT+3', 'Etc/GMT+4', 'Etc/GMT+5',
'Etc/GMT+6', 'Etc/GMT+7', 'Etc/GMT+8', 'Etc/GMT+9', 'Etc/GMT-0', 'Etc/GMT-1',
'Etc/GMT-10', 'Etc/GMT-11', 'Etc/GMT-12', 'Etc/GMT-13', 'Etc/GMT-14', 'Etc/GMT-2',
'Etc/GMT-3', 'Etc/GMT-4', 'Etc/GMT-5', 'Etc/GMT-6', 'Etc/GMT-7', 'Etc/GMT-8',
'Etc/GMT-9', 'Etc/GMT0', 'Etc/Greenwich', 'Etc/UCT', 'Etc/Universal', 'Etc/UTC',
'Etc/Zulu', 'Factory GB', 'GB-Eire', 'GMT', 'GMT+0', 'GMT-0', 'GMT0', 'Greenwich',
'Hongkong', 'HST', 'Iceland', 'Iran', 'Israel', 'Jamaica', 'Japan', 'Kwajalein',
'Libya', 'MET', 'Mexico/BajaNorte', 'Mexico/BajaSur', 'Mexico/General',
'MST', 'MST7MDT', 'Navajo', 'NZ', 'NZ-CHAT', 'Poland', 'Portugal', 'PRC',
'PST8PDT', 'ROC', 'ROK', 'Singapore', 'Turkey', 'UCT', 'Universal', 'US/Alaska',
'US/Aleutian', 'US/Arizona', 'US/Central', 'US/East-Indiana', 'US/Eastern',
'US/Hawaii', 'US/Indiana-Starke', 'US/Michigan', 'US/Mountain', 'US/Pacific',
'US/Pacific-New', 'US/Samoa', 'UTC', 'W-SU', 'WET', 'Zulu');
- /lib/max/language/Loader.phpを参照
// Load translations
require_once MAX_PATH .'/lib/max/language/Loader.php';
Language_Loader::load('timezone');
- /lib/pear/Date/TimeZone.phpを参照
// Load global array of timezones
require_once MAX_PATH .'/lib/pear/Date/TimeZone.php';
$aTimezoneKey = Date_TimeZone::getAvailableIDs();
if (!defined('MAX_PATH')) {
$tz = OX_Admin_Timezones::getTimezone();
} else {
$tz = $GLOBALS['_MAX']['PREF']['timezone'];
if (is_null($tz)) {
$tz = OX_Admin_Timezones::getTimezone();
}
}
$tzSave = date_default_timezone_get();
foreach ($aTimezoneKey as $key) {
if (!@date_default_timezone_set($key)) continue;
if ((in_array($tz, $_aTimezoneBcData) && $key == $tz) || !in_array($key, $_aTimezoneBcData)) {
// Calculate the timezone offset
$offset = OX_Admin_Timezones::_convertOffset($_DATE_TIMEZONE_DATA[$key]['offset']);
// Build the arrays used for sorting time zones
$origOffset = $_DATE_TIMEZONE_DATA[$key]['offset'];
$key = (!empty($GLOBALS['strTimezoneList'][$key])) ? $GLOBALS['strTimezoneList'][$key] : $key;
if ($origOffset >= 0) {
$aTimezone[$offset][$key] = "(GMT+$offset) $key";
} else {
$aNegTimezone[$key] = "(GMT-$offset) $key";
}
}
}
date_default_timezone_set($tzSave);
// Sort timezones with positive offsets descending, and negative
// offests ascending.
// Add initial empty key/value pair
if ($addBlank) {
$aResult[] = '';
}
// Sort time zones
asort($aNegTimezone);
// Reverse array element order while preserving alphabetical order
$hasRun = false;
foreach ($aTimezone as $offset => $aValue) {
if ($hasRun == false) {
$aRevTimezone[] = $aValue;
$hasRun = true;
} else {
array_unshift($aRevTimezone, $aValue);
}
}
// Build the result array
foreach($aRevTimezone as $aValue) {
foreach ($aValue as $k => $v) {
$aResult[$k] = $v;
}
}
foreach ($aNegTimezone as $key => $value) {
$aResult[$key] = $value;
}
return $aResult;
}
コメント