/**
  * Seek to the previous timezone transition
  *
  * @throws  lang.IllegalArgumentException if timezone has no transitions
  */
 public function previous()
 {
     $ts = $this->date->getTime();
     foreach (timezone_transitions_get($this->tz->getHandle()) as $t) {
         if ($t['ts'] >= $ts) {
             break;
         }
         $last = $t;
     }
     if (!isset($t)) {
         throw new IllegalArgumentException('Timezone ' . $this->tz->getName() . ' does not have DST transitions.');
     }
     $this->date = new Date($last['ts'], $this->date->getTimeZone());
     $this->isDst = $last['isdst'];
     $this->offset = $last['offset'];
     $this->abbr = $last['abbr'];
 }
Exemplo n.º 2
0
 /**
  * The magic function that does everything.
  * 
  **/
 function magic2()
 {
     if (!in_array($this->tz_file, $this->valid_names)) {
         trigger_error(sprintf('Bad timezone name given: %s', $this->tz_file), E_USER_ERROR);
     }
     // TODO: move msg to lang
     $tz_obj = timezone_open($this->tz_file);
     $tz_data = timezone_transitions_get($tz_obj);
     $last = reset($tz_data);
     $now = time();
     foreach ($tz_data as $transition) {
         if ($transition['ts'] > $now) {
             $this->gmt_offset = $last['offset'];
             $this->abba = $last['abbr'];
             $this->next_update = $transition['ts'];
             return;
         } else {
             $last = $transition;
         }
     }
     // default to the last entry if we get here
     $this->gmt_offset = $last['offset'];
     $this->abba = $last['abbr'];
 }
    /**
     * @access public
     * @param string $timezone_string
     */
    public static function timezone_select_input($timezone_string = '')
    {
        // get WP date time format
        $datetime_format = get_option('date_format') . ' ' . get_option('time_format');
        // if passed a value, then use that, else get WP option
        $timezone_string = !empty($timezone_string) ? $timezone_string : get_option('timezone_string');
        // check if the timezone is valid but don't throw any errors if it isn't
        $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
        $gmt_offset = get_option('gmt_offset');
        $check_zone_info = true;
        if (empty($timezone_string)) {
            // Create a UTC+- zone if no timezone string exists
            $check_zone_info = false;
            if ($gmt_offset > 0) {
                $timezone_string = 'UTC+' . $gmt_offset;
            } elseif ($gmt_offset < 0) {
                $timezone_string = 'UTC' . $gmt_offset;
            } else {
                $timezone_string = 'UTC';
            }
        }
        ?>

		<p>
			<label for="timezone_string"><?php 
        _e('timezone');
        ?>
</label>
			<select id="timezone_string" name="timezone_string">
				<?php 
        echo wp_timezone_choice($timezone_string);
        ?>
			</select>
			<br />
			<span class="description"><?php 
        _e('Choose a city in the same timezone as the event.');
        ?>
</span>
		</p>

		<p>
			<span><?php 
        printf(__('%1$sUTC%2$s time is %3$s'), '<abbr title="Coordinated Universal Time">', '</abbr>', '<code>' . date_i18n($datetime_format, false, 'gmt') . '</code>');
        ?>
</span>
			<?php 
        if (!empty($timezone_string) || !empty($gmt_offset)) {
            ?>
				<br /><span><?php 
            printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>');
            ?>
</span>
		<?php 
        }
        ?>

				<?php 
        if ($check_zone_info && $timezone_string) {
            ?>
				<br />
				<span>
					<?php 
            // Set TZ so localtime works.
            date_default_timezone_set($timezone_string);
            $now = localtime(time(), true);
            if ($now['tm_isdst']) {
                _e('This timezone is currently in daylight saving time.');
            } else {
                _e('This timezone is currently in standard time.');
            }
            ?>
					<br />
					<?php 
            if (function_exists('timezone_transitions_get')) {
                $found = false;
                $date_time_zone_selected = new DateTimeZone($timezone_string);
                $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
                $right_now = time();
                $tr['isdst'] = false;
                foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
                    if ($tr['ts'] > $right_now) {
                        $found = true;
                        break;
                    }
                }
                if ($found) {
                    $message = $tr['isdst'] ? __(' Daylight saving time begins on: %s.') : __(' Standard time begins  on: %s.');
                    // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
                    printf($message, '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >');
                } else {
                    _e('This timezone does not observe daylight saving time.');
                }
            }
            // Set back to UTC.
            date_default_timezone_set('UTC');
            ?>
				</span></p>
			<?php 
        }
    }
Exemplo n.º 4
0
var_dump(date_format($dt, 'Y-m-d H:i:s'));
var_dump(timezone_name_from_abbr("CET"));
var_dump(timezone_name_from_abbr("", 3600, 0));
$tz = timezone_open("Asia/Shanghai");
var_dump(timezone_name_get($tz));
// Create two timezone objects, one for Taipei (Taiwan) and one for
// Tokyo (Japan)
$dateTimeZoneTaipei = timezone_open("Asia/Taipei");
$dateTimeZoneJapan = timezone_open("Asia/Tokyo");
// Create two DateTime objects that will contain the same Unix timestamp, but
// have different timezones attached to them.
$dateTimeTaipei = date_create("2008-08-08", $dateTimeZoneTaipei);
$dateTimeJapan = date_create("2008-08-08", $dateTimeZoneJapan);
var_dump(date_offset_get($dateTimeTaipei));
var_dump(date_offset_get($dateTimeJapan));
$tz = timezone_open("Asia/Shanghai");
var_dump(timezone_name_get($tz));
$timezone = timezone_open("CET");
$transitions = timezone_transitions_get($timezone);
var_dump($transitions[0]['ts']);
var_dump($transitions[0]['offset']);
var_dump($transitions[0]['isdst']);
var_dump($transitions[0]['abbr']);
$tz = timezone_open("EDT");
var_dump(timezone_name_get($tz));
$tz = timezone_open("PST");
var_dump(timezone_name_get($tz));
$tz = timezone_open("CHAST");
var_dump(timezone_name_get($tz));
var_dump((bool) timezone_version_get());
var_dump(timezone_open('sdf'));
Exemplo n.º 5
0
$zones = timezone_identifiers_list(DateTimeZone::ALL_WITH_BC);
$priorityA = array('acst' => 'America/Porto_Acre', 'act' => 'America/Porto_Acre', 'acdt' => 'Australia/Adelaide', 'acst' => 'Australia/Adelaide', 'addt' => 'America/Goose_Bay', 'adt' => 'America/Halifax', 'aedt' => 'Australia/Melbourne', 'aest' => 'Australia/Melbourne', 'aft' => 'Asia/Kabul', 'ahdt' => 'America/Anchorage', 'ahst' => 'America/Anchorage', 'akdt' => 'America/Anchorage', 'akst' => 'America/Anchorage', 'aktst' => 'Asia/Aqtobe', 'aktt' => 'Asia/Aqtobe', 'almst' => 'Asia/Almaty', 'almt' => 'Asia/Almaty', 'amst' => 'Asia/Yerevan', 'amt' => 'Asia/Yerevan', 'anast' => 'Asia/Anadyr', 'anat' => 'Asia/Anadyr', 'ant' => 'America/Curacao', 'apt' => 'America/Halifax', 'aqtst' => 'Asia/Aqtau', 'aqtt' => 'Asia/Aqtau', 'arst' => 'America/Buenos_Aires', 'art' => 'America/Buenos_Aires', 'ashst' => 'Asia/Ashkhabad', 'asht' => 'Asia/Ashkhabad', 'ast' => 'Asia/Riyadh', 'awt' => 'America/Halifax', 'awdt' => 'Australia/Perth', 'awst' => 'Australia/Perth', 'azomt' => 'Atlantic/Azores', 'azost' => 'Atlantic/Azores', 'azot' => 'Atlantic/Azores', 'azst' => 'Asia/Baku', 'azt' => 'Asia/Baku', 'bakst' => 'Asia/Baku', 'bakt' => 'Asia/Baku', 'bdst' => 'Europe/London', 'bdt' => 'America/Adak', 'beat' => 'Africa/Mogadishu', 'beaut' => 'Africa/Nairobi', 'bmt' => 'America/Barbados', 'bnt' => 'Asia/Brunei', 'bortst' => 'Asia/Kuching', 'bort' => 'Asia/Kuching', 'bost' => 'America/La_Paz', 'bot' => 'America/La_Paz', 'brst' => 'America/Sao_Paulo', 'brt' => 'America/Sao_Paulo', 'bst' => 'Europe/London', 'btt' => 'Asia/Thimbu', 'burt' => 'Asia/Kolkata', 'cadt' => 'Australia/Adelaide', 'cant' => 'Atlantic/Canary', 'cast' => 'Australia/Adelaide', 'cat' => 'America/Anchorage', 'cawt' => 'America/Anchorage', 'cddt' => 'America/Rankin_Inlet', 'cdt' => 'America/Chicago', 'cemt' => 'Europe/Berlin', 'cest' => 'Europe/Berlin', 'cet' => 'Europe/Berlin', 'cgst' => 'America/Scoresbysund', 'cgt' => 'America/Scoresbysund', 'chadt' => 'Pacific/Chatham', 'chast' => 'Pacific/Chatham', 'chat' => 'Asia/Harbin', 'chdt' => 'America/Belize', 'chost' => 'Asia/Choibalsan', 'chot' => 'Asia/Choibalsan', 'cit' => 'Asia/Dili', 'cjt' => 'Asia/Sakhalin', 'ckhst' => 'Pacific/Rarotonga', 'ckt' => 'Pacific/Rarotonga', 'clst' => 'America/Santiago', 'clt' => 'America/Santiago', 'cost' => 'America/Bogota', 'cot' => 'America/Bogota', 'cpt' => 'America/Chicago', 'cst' => 'America/Chicago', 'cvst' => 'Atlantic/Cape_Verde', 'cvt' => 'Atlantic/Cape_Verde', 'cwt' => 'America/Chicago', 'chst' => 'Pacific/Guam', 'dact' => 'Asia/Dacca', 'davt' => 'Antarctica/Davis', 'ddut' => 'Antarctica/DumontDUrville', 'dusst' => 'Asia/Dushanbe', 'dust' => 'Asia/Dushanbe', 'easst' => 'Chile/EasterIsland', 'east' => 'Chile/EasterIsland', 'eat' => 'Africa/Khartoum', 'ect' => 'America/Guayaquil', 'eddt' => 'America/Iqaluit', 'edt' => 'America/New_York', 'eest' => 'Europe/Helsinki', 'eet' => 'Europe/Helsinki', 'egst' => 'America/Scoresbysund', 'egt' => 'America/Scoresbysund', 'ehdt' => 'America/Santo_Domingo', 'eit' => 'Asia/Jayapura', 'ept' => 'America/New_York', 'est' => 'America/New_York', 'ewt' => 'America/New_York', 'fjst' => 'Pacific/Fiji', 'fjt' => 'Pacific/Fiji', 'fkst' => 'Atlantic/Stanley', 'fkt' => 'Atlantic/Stanley', 'fnst' => 'America/Noronha', 'fnt' => 'America/Noronha', 'fort' => 'Asia/Aqtau', 'frust' => 'Asia/Bishkek', 'frut' => 'Asia/Bishkek', 'galt' => 'Pacific/Galapagos', 'gamt' => 'Pacific/Gambier', 'gbgt' => 'America/Guyana', 'gest' => 'Asia/Tbilisi', 'get' => 'Asia/Tbilisi', 'gft' => 'America/Cayenne', 'ghst' => 'Africa/Accra', 'gst' => 'Asia/Dubai', 'gyt' => 'America/Guyana', 'hadt' => 'America/Adak', 'hast' => 'America/Adak', 'hdt' => 'Pacific/Honolulu', 'hkst' => 'Asia/Hong_Kong', 'hkt' => 'Asia/Hong_Kong', 'hovst' => 'Asia/Hovd', 'hovt' => 'Asia/Hovd', 'hpt' => 'Pacific/Honolulu', 'hst' => 'Pacific/Honolulu', 'hwt' => 'Pacific/Honolulu', 'ict' => 'Asia/Bangkok', 'iddt' => 'Asia/Jerusalem', 'idt' => 'Asia/Jerusalem', 'ihst' => 'Asia/Colombo', 'iot' => 'Indian/Chagos', 'irdt' => 'Asia/Tehran', 'irkst' => 'Asia/Irkutsk', 'irkt' => 'Asia/Irkutsk', 'irst' => 'Asia/Tehran', 'isst' => 'Atlantic/Reykjavik', 'ist' => 'Asia/Jerusalem', 'javt' => 'Asia/Jakarta', 'jdt' => 'Asia/Tokyo', 'jst' => 'Asia/Tokyo', 'kart' => 'Asia/Karachi', 'kast' => 'Asia/Kashgar', 'kdt' => 'Asia/Seoul', 'kgst' => 'Asia/Bishkek', 'kgt' => 'Asia/Bishkek', 'kizst' => 'Asia/Qyzylorda', 'kizt' => 'Asia/Qyzylorda', 'kmt' => 'Europe/Vilnius', 'kost' => 'Pacific/Kosrae', 'krast' => 'Asia/Krasnoyarsk', 'krat' => 'Asia/Krasnoyarsk', 'kst' => 'Asia/Seoul', 'kuyst' => 'Europe/Samara', 'kuyt' => 'Europe/Samara', 'kwat' => 'Kwajalein', 'kwat' => 'Pacific/Kwajalein', 'lhst' => 'Australia/Lord_Howe', 'lint' => 'Pacific/Kiritimati', 'lkt' => 'Asia/Colombo', 'lont' => 'Asia/Chongqing', 'lrt' => 'Africa/Monrovia', 'lst' => 'Europe/Riga', 'madmt' => 'Atlantic/Madeira', 'madst' => 'Atlantic/Madeira', 'madt' => 'Atlantic/Madeira', 'magst' => 'Asia/Magadan', 'magt' => 'Asia/Magadan', 'malst' => 'Asia/Singapore', 'malt' => 'Asia/Singapore', 'mart' => 'Pacific/Marquesas', 'mawt' => 'Antarctica/Mawson', 'mddt' => 'America/Cambridge_Bay', 'mdst' => 'Europe/Moscow', 'mdt' => 'America/Denver', 'mht' => 'Pacific/Kwajalein', 'mmt' => 'Europe/Moscow', 'most' => 'Asia/Macao', 'mot' => 'Asia/Macao', 'mpt' => 'America/Denver', 'msd' => 'Europe/Moscow', 'msk' => 'Europe/Moscow', 'mst' => 'America/Denver', 'mut' => 'Indian/Mauritius', 'mvt' => 'Indian/Maldives', 'mwt' => 'America/Denver', 'myt' => 'Asia/Kuala_Lumpur', 'ncst' => 'Pacific/Noumea', 'nct' => 'Pacific/Noumea', 'nddt' => 'America/St_Johns', 'ndt' => 'America/St_Johns', 'negt' => 'America/Paramaribo', 'nest' => 'Europe/Amsterdam', 'net' => 'Europe/Amsterdam', 'nft' => 'Pacific/Norfolk', 'novst' => 'Asia/Novosibirsk', 'novt' => 'Asia/Novosibirsk', 'npt' => 'America/St_Johns', 'nrt' => 'Pacific/Nauru', 'nst' => 'America/St_Johns', 'nut' => 'Pacific/Niue', 'nwt' => 'America/St_Johns', 'nzdt' => 'Pacific/Auckland', 'nzmt' => 'Pacific/Auckland', 'nzst' => 'Pacific/Auckland', 'omsst' => 'Asia/Omsk', 'omst' => 'Asia/Omsk', 'orast' => 'Asia/Oral', 'orat' => 'Asia/Oral', 'pddt' => 'America/Inuvik', 'pdt' => 'America/Los_Angeles', 'pest' => 'America/Lima', 'petst' => 'Asia/Kamchatka', 'pett' => 'Asia/Kamchatka', 'pet' => 'America/Lima', 'phot' => 'Pacific/Enderbury', 'phst' => 'Asia/Manila', 'pht' => 'Asia/Manila', 'pkst' => 'Asia/Karachi', 'pkt' => 'Asia/Karachi', 'pmdt' => 'America/Miquelon', 'pmst' => 'America/Miquelon', 'pmt' => 'America/Paramaribo', 'ppt' => 'America/Los_Angeles', 'pst' => 'America/Los_Angeles', 'pwt' => 'America/Los_Angeles', 'pyst' => 'America/Asuncion', 'pyt' => 'America/Asuncion', 'qyzst' => 'Asia/Qyzylorda', 'qyzt' => 'Asia/Qyzylorda', 'ret' => 'Indian/Reunion', 'rmt' => 'Europe/Riga', 'rott' => 'Antarctica/Rothera', 'sakst' => 'Asia/Sakhalin', 'sakt' => 'Asia/Sakhalin', 'samst' => 'Asia/Samarkand', 'samt' => 'Asia/Samarkand', 'sast' => 'Africa/Johannesburg', 'sbt' => 'Pacific/Guadalcanal', 'sct' => 'Indian/Mahe', 'sgt' => 'Asia/Singapore', 'shest' => 'Asia/Aqtau', 'shet' => 'Asia/Aqtau', 'slst' => 'Africa/Freetown', 'smt' => 'Asia/Saigon', 'srt' => 'America/Paramaribo', 'sst' => 'Pacific/Samoa', 'svest' => 'Asia/Yekaterinburg', 'svet' => 'Asia/Yekaterinburg', 'syot' => 'Antarctica/Syowa', 'taht' => 'Pacific/Tahiti', 'tasst' => 'Asia/Samarkand', 'tast' => 'Asia/Samarkand', 'tbist' => 'Asia/Tbilisi', 'tbit' => 'Asia/Tbilisi', 'tft' => 'Indian/Kerguelen', 'tjt' => 'Asia/Dushanbe', 'tlt' => 'Asia/Dili', 'tlt' => 'Asia/Dili', 'tmt' => 'Asia/Tehran', 'tost' => 'Pacific/Tongatapu', 'tot' => 'Pacific/Tongatapu', 'trst' => 'Europe/Istanbul', 'trt' => 'Europe/Istanbul', 'ulast' => 'Asia/Ulaanbaatar', 'ulat' => 'Asia/Ulaanbaatar', 'urast' => 'Asia/Oral', 'urat' => 'Asia/Oral', 'urut' => 'Asia/Urumqi', 'uyhst' => 'America/Montevideo', 'uyst' => 'America/Montevideo', 'uyt' => 'America/Montevideo', 'uzst' => 'Asia/Samarkand', 'uzt' => 'Asia/Samarkand', 'vet' => 'America/Caracas', 'vlasst' => 'Asia/Vladivostok', 'vlast' => 'Asia/Vladivostok', 'vlat' => 'Asia/Vladivostok', 'vost' => 'Antarctica/Vostok', 'vust' => 'Pacific/Efate', 'vut' => 'Pacific/Efate', 'warst' => 'America/Mendoza', 'wart' => 'America/Mendoza', 'wast' => 'Africa/Windhoek', 'wat' => 'Africa/Dakar', 'wemt' => 'Europe/Lisbon', 'west' => 'Europe/Paris', 'wet' => 'Europe/Paris', 'wgst' => 'America/Godthab', 'wgt' => 'America/Godthab', 'wit' => 'Asia/Jakarta', 'wst' => 'Australia/Perth', 'yakst' => 'Asia/Yakutsk', 'yakt' => 'Asia/Yakutsk', 'yddt' => 'America/Dawson', 'ydt' => 'America/Dawson', 'yekst' => 'Asia/Yekaterinburg', 'yekt' => 'Asia/Yekaterinburg', 'yerst' => 'Asia/Yerevan', 'yert' => 'Asia/Yerevan', 'ypt' => 'America/Dawson', 'yst' => 'America/Anchorage', 'ywt' => 'America/Dawson', 'zzz' => 'Antarctica/Davis');
$priorityB = array('acst' => array(1, -14400, 'America/Porto_Acre'), 'act' => array(0, -18000, 'America/Porto_Acre'), 'addt' => array(1, -7200, 'America/Goose_Bay'), 'adt' => array(1, -10800, 'America/Halifax'), 'aft' => array(0, 16200, 'Asia/Kabul'), 'ahdt' => array(1, -32400, 'America/Anchorage'), 'ahst' => array(0, -36000, 'America/Anchorage'), 'akdt' => array(1, -28800, 'America/Anchorage'), 'akst' => array(0, -32400, 'America/Anchorage'), 'aktst' => array(1, 21600, 'Asia/Aqtobe'), 'aktt' => array(0, 14400, 'Asia/Aqtobe'), 'aktt' => array(0, 18000, 'Asia/Aqtobe'), 'aktt' => array(0, 21600, 'Asia/Aqtobe'), 'almst' => array(1, 25200, 'Asia/Almaty'), 'almt' => array(0, 18000, 'Asia/Almaty'), 'almt' => array(0, 21600, 'Asia/Almaty'), 'amst' => array(1, -10800, 'America/Manaus'), 'amst' => array(1, 14400, 'Asia/Yerevan'), 'amst' => array(1, 18000, 'Asia/Yerevan'), 'amt' => array(0, -14400, 'America/Manaus'), 'amt' => array(0, 10800, 'Asia/Yerevan'), 'amt' => array(0, 1172, 'Europe/Amsterdam'), 'amt' => array(0, 14400, 'Asia/Yerevan'), 'anast' => array(1, 43200, 'Asia/Anadyr'), 'anast' => array(1, 46800, 'Asia/Anadyr'), 'anast' => array(1, 50400, 'Asia/Anadyr'), 'anat' => array(0, 39600, 'Asia/Anadyr'), 'anat' => array(0, 43200, 'Asia/Anadyr'), 'anat' => array(0, 46800, 'Asia/Anadyr'), 'ant' => array(0, -16200, 'America/Curacao'), 'apt' => array(1, -10800, 'America/Halifax'), 'aqtst' => array(1, 18000, 'Asia/Aqtau'), 'aqtst' => array(1, 21600, 'Asia/Aqtau'), 'aqtt' => array(0, 14400, 'Asia/Aqtau'), 'aqtt' => array(0, 18000, 'Asia/Aqtau'), 'arst' => array(1, -7200, 'America/Buenos_Aires'), 'art' => array(0, -10800, 'America/Buenos_Aires'), 'ashst' => array(1, 18000, 'Asia/Ashkhabad'), 'ashst' => array(1, 21600, 'Asia/Ashkhabad'), 'asht' => array(0, 14400, 'Asia/Ashkhabad'), 'asht' => array(0, 18000, 'Asia/Ashkhabad'), 'ast' => array(0, -14400, 'America/Curacao'), 'ast' => array(0, 10800, 'Asia/Riyadh'), 'awt' => array(1, -10800, 'America/Halifax'), 'azomt' => array(1, 0, 'Atlantic/Azores'), 'azost' => array(1, 0, 'Atlantic/Azores'), 'azot' => array(0, -3600, 'Atlantic/Azores'), 'azst' => array(1, 14400, 'Asia/Baku'), 'azst' => array(1, 18000, 'Asia/Baku'), 'azt' => array(0, 10800, 'Asia/Baku'), 'azt' => array(0, 14400, 'Asia/Baku'), 'bakst' => array(1, 14400, 'Asia/Baku'), 'bakst' => array(1, 18000, 'Asia/Baku'), 'bakt' => array(0, 10800, 'Asia/Baku'), 'bakt' => array(0, 14400, 'Asia/Baku'), 'bdst' => array(1, 7200, 'Europe/London'), 'bdt' => array(1, -36000, 'America/Adak'), 'bdt' => array(0, 21600, 'Asia/Dacca'), 'beat' => array(0, 9000, 'Africa/Mogadishu'), 'beaut' => array(0, 9885, 'Africa/Nairobi'), 'bmt' => array(0, -14308, 'America/Barbados'), 'bmt' => array(0, -3996, 'Africa/Banjul'), 'bmt' => array(0, 6264, 'Europe/Tiraspol'), 'bnt' => array(0, 27000, 'Asia/Brunei'), 'bnt' => array(0, 28800, 'Asia/Brunei'), 'bortst' => array(1, 30000, 'Asia/Kuching'), 'bort' => array(0, 27000, 'Asia/Kuching'), 'bort' => array(0, 28800, 'Asia/Kuching'), 'bost' => array(1, -12756, 'America/La_Paz'), 'bot' => array(0, -14400, 'America/La_Paz'), 'brst' => array(1, -7200, 'America/Sao_Paulo'), 'brt' => array(0, -10800, 'America/Sao_Paulo'), 'bst' => array(0, -39600, 'America/Adak'), 'bst' => array(0, 3600, 'Europe/London'), 'bst' => array(1, 3600, 'Europe/London'), 'btt' => array(0, 21600, 'Asia/Thimbu'), 'burt' => array(0, 23400, 'Asia/Kolkata'), 'cant' => array(0, -3600, 'Atlantic/Canary'), 'cast' => array(0, 34200, 'Australia/Adelaide'), 'cat' => array(0, -36000, 'America/Anchorage'), 'cat' => array(0, 7200, 'Africa/Khartoum'), 'cawt' => array(1, -32400, 'America/Anchorage'), 'cddt' => array(1, -14400, 'America/Rankin_Inlet'), 'cdt' => array(1, -14400, 'America/Havana'), 'cdt' => array(1, -18000, 'America/Chicago'), 'cdt' => array(1, 32400, 'Asia/Shanghai'), 'cemt' => array(1, 10800, 'Europe/Berlin'), 'cest' => array(1, 10800, 'Europe/Kaliningrad'), 'cest' => array(1, 7200, 'Europe/Berlin'), 'cet' => array(0, 3600, 'Europe/Berlin'), 'cet' => array(0, 7200, 'Europe/Kaliningrad'), 'cgst' => array(1, -3600, 'America/Scoresbysund'), 'cgt' => array(0, -7200, 'America/Scoresbysund'), 'chadt' => array(1, 49500, 'Pacific/Chatham'), 'chast' => array(0, 45900, 'Pacific/Chatham'), 'chat' => array(0, 30600, 'Asia/Harbin'), 'chat' => array(0, 32400, 'Asia/Harbin'), 'chdt' => array(1, -19800, 'America/Belize'), 'chost' => array(1, 36000, 'Asia/Choibalsan'), 'chot' => array(0, 32400, 'Asia/Choibalsan'), 'cit' => array(0, 28800, 'Asia/Dili'), 'cjt' => array(0, 32400, 'Asia/Sakhalin'), 'ckhst' => array(1, -34200, 'Pacific/Rarotonga'), 'ckt' => array(0, -36000, 'Pacific/Rarotonga'), 'clst' => array(1, -10800, 'America/Santiago'), 'clt' => array(0, -14400, 'America/Santiago'), 'cost' => array(1, -14400, 'America/Bogota'), 'cot' => array(0, -18000, 'America/Bogota'), 'cpt' => array(1, -18000, 'America/Chicago'), 'cst' => array(0, -18000, 'America/Havana'), 'cst' => array(0, -21600, 'America/Chicago'), 'cst' => array(0, 28800, 'Asia/Shanghai'), 'cst' => array(0, 34200, 'Australia/Adelaide'), 'cst' => array(1, 37800, 'Australia/Adelaide'), 'cvst' => array(1, -3600, 'Atlantic/Cape_Verde'), 'cvt' => array(0, -3600, 'Atlantic/Cape_Verde'), 'cvt' => array(0, -7200, 'Atlantic/Cape_Verde'), 'cwt' => array(1, -18000, 'America/Chicago'), 'chst' => array(0, 36000, 'Pacific/Guam'), 'dact' => array(0, 21600, 'Asia/Dacca'), 'davt' => array(0, 25200, 'Antarctica/Davis'), 'ddut' => array(0, 36000, 'Antarctica/DumontDUrville'), 'dusst' => array(1, 21600, 'Asia/Dushanbe'), 'dusst' => array(1, 25200, 'Asia/Dushanbe'), 'dust' => array(0, 18000, 'Asia/Dushanbe'), 'dust' => array(0, 21600, 'Asia/Dushanbe'), 'easst' => array(1, -18000, 'Chile/EasterIsland'), 'easst' => array(1, -21600, 'Chile/EasterIsland'), 'east' => array(0, -21600, 'Chile/EasterIsland'), 'east' => array(0, -25200, 'Chile/EasterIsland'), 'east' => array(1, 14400, 'Indian/Antananarivo'), 'eat' => array(0, 10800, 'Africa/Khartoum'), 'ect' => array(0, -18000, 'America/Guayaquil'), 'eddt' => array(1, -10800, 'America/Iqaluit'), 'edt' => array(1, -14400, 'America/New_York'), 'eest' => array(1, 10800, 'Europe/Helsinki'), 'eet' => array(0, 7200, 'Europe/Helsinki'), 'egst' => array(1, 0, 'America/Scoresbysund'), 'egt' => array(0, -3600, 'America/Scoresbysund'), 'ehdt' => array(1, -16200, 'America/Santo_Domingo'), 'eit' => array(0, 32400, 'Asia/Jayapura'), 'ept' => array(1, -14400, 'America/New_York'), 'est' => array(0, -18000, 'America/New_York'), 'est' => array(0, 36000, 'Australia/Melbourne'), 'est' => array(1, 39600, 'Australia/Melbourne'), 'ewt' => array(1, -14400, 'America/New_York'), 'fjst' => array(1, 46800, 'Pacific/Fiji'), 'fjt' => array(0, 43200, 'Pacific/Fiji'), 'fkst' => array(1, -10800, 'Atlantic/Stanley'), 'fkst' => array(1, -7200, 'Atlantic/Stanley'), 'fkt' => array(0, -10800, 'Atlantic/Stanley'), 'fkt' => array(0, -14400, 'Atlantic/Stanley'), 'fnst' => array(1, -3600, 'America/Noronha'), 'fnt' => array(0, -7200, 'America/Noronha'), 'fort' => array(0, 14400, 'Asia/Aqtau'), 'fort' => array(0, 18000, 'Asia/Aqtau'), 'frust' => array(1, 21600, 'Asia/Bishkek'), 'frust' => array(1, 25200, 'Asia/Bishkek'), 'frut' => array(0, 18000, 'Asia/Bishkek'), 'frut' => array(0, 21600, 'Asia/Bishkek'), 'galt' => array(0, -21600, 'Pacific/Galapagos'), 'gamt' => array(0, -32400, 'Pacific/Gambier'), 'gbgt' => array(0, -13500, 'America/Guyana'), 'gest' => array(1, 14400, 'Asia/Tbilisi'), 'get' => array(0, 10800, 'Asia/Tbilisi'), 'get' => array(0, 14400, 'Asia/Tbilisi'), 'gft' => array(0, -10800, 'America/Cayenne'), 'gft' => array(0, -14400, 'America/Cayenne'), 'ghst' => array(1, 1200, 'Africa/Accra'), 'gst' => array(0, 14400, 'Asia/Dubai'), 'gyt' => array(0, -14400, 'America/Guyana'), 'hadt' => array(1, -32400, 'America/Adak'), 'hast' => array(0, -36000, 'America/Adak'), 'hdt' => array(1, -34200, 'Pacific/Honolulu'), 'hkst' => array(1, 32400, 'Asia/Hong_Kong'), 'hkt' => array(0, 28800, 'Asia/Hong_Kong'), 'hovst' => array(1, 28800, 'Asia/Hovd'), 'hovt' => array(0, 21600, 'Asia/Hovd'), 'hovt' => array(0, 25200, 'Asia/Hovd'), 'hpt' => array(1, -34200, 'Pacific/Honolulu'), 'hst' => array(0, -36000, 'Pacific/Honolulu'), 'hwt' => array(1, -34200, 'Pacific/Honolulu'), 'ict' => array(0, 25200, 'Asia/Bangkok'), 'iddt' => array(1, 14400, 'Asia/Jerusalem'), 'idt' => array(1, 10800, 'Asia/Jerusalem'), 'ihst' => array(1, 21600, 'Asia/Colombo'), 'iot' => array(0, 18000, 'Indian/Chagos'), 'iot' => array(0, 21600, 'Indian/Chagos'), 'irdt' => array(1, 16200, 'Asia/Tehran'), 'irkst' => array(1, 28800, 'Asia/Irkutsk'), 'irkst' => array(1, 32400, 'Asia/Irkutsk'), 'irkt' => array(0, 25200, 'Asia/Irkutsk'), 'irkt' => array(0, 28800, 'Asia/Irkutsk'), 'irst' => array(0, 12600, 'Asia/Tehran'), 'isst' => array(1, 0, 'Atlantic/Reykjavik'), 'ist' => array(0, -3600, 'Atlantic/Reykjavik'), 'ist' => array(0, 19800, 'Asia/Kolkata'), 'ist' => array(1, 2079, 'Europe/Dublin'), 'ist' => array(1, 23400, 'Asia/Kolkata'), 'ist' => array(0, 3600, 'Europe/Dublin'), 'ist' => array(1, 3600, 'Europe/Dublin'), 'ist' => array(0, 7200, 'Asia/Jerusalem'), 'javt' => array(0, 26400, 'Asia/Jakarta'), 'jdt' => array(1, 36000, 'Asia/Tokyo'), 'jst' => array(0, 32400, 'Asia/Tokyo'), 'kart' => array(0, 18000, 'Asia/Karachi'), 'kast' => array(0, 18000, 'Asia/Kashgar'), 'kast' => array(0, 19800, 'Asia/Kashgar'), 'kdt' => array(1, 36000, 'Asia/Seoul'), 'kgst' => array(1, 21600, 'Asia/Bishkek'), 'kgt' => array(0, 18000, 'Asia/Bishkek'), 'kizst' => array(1, 21600, 'Asia/Qyzylorda'), 'kizt' => array(0, 14400, 'Asia/Qyzylorda'), 'kizt' => array(0, 18000, 'Asia/Qyzylorda'), 'kizt' => array(0, 21600, 'Asia/Qyzylorda'), 'kmt' => array(0, 5736, 'Europe/Vilnius'), 'kost' => array(0, 39600, 'Pacific/Kosrae'), 'kost' => array(0, 43200, 'Pacific/Kosrae'), 'krast' => array(1, 25200, 'Asia/Krasnoyarsk'), 'krast' => array(1, 28800, 'Asia/Krasnoyarsk'), 'krat' => array(0, 21600, 'Asia/Krasnoyarsk'), 'krat' => array(0, 25200, 'Asia/Krasnoyarsk'), 'kst' => array(0, 32400, 'Asia/Seoul'), 'kst' => array(0, 30600, 'Asia/Pyongyang'), 'kst' => array(0, 32400, 'Asia/Pyongyang'), 'kuyst' => array(1, 10800, 'Europe/Samara'), 'kuyst' => array(1, 14400, 'Europe/Samara'), 'kuyst' => array(1, 18000, 'Europe/Samara'), 'kuyt' => array(0, 10800, 'Europe/Samara'), 'kuyt' => array(0, 14400, 'Europe/Samara'), 'kwat' => array(0, -43200, 'Kwajalein'), 'kwat' => array(0, -43200, 'Pacific/Kwajalein'), 'lhst' => array(0, 37800, 'Australia/Lord_Howe'), 'lhst' => array(1, 39600, 'Australia/Lord_Howe'), 'lhst' => array(1, 41400, 'Australia/Lord_Howe'), 'lint' => array(0, -36000, 'Pacific/Kiritimati'), 'lint' => array(0, 50400, 'Pacific/Kiritimati'), 'lkt' => array(0, 21600, 'Asia/Colombo'), 'lkt' => array(0, 23400, 'Asia/Colombo'), 'lont' => array(0, 25200, 'Asia/Chongqing'), 'lrt' => array(0, -2670, 'Africa/Monrovia'), 'lst' => array(1, 9384, 'Europe/Riga'), 'madmt' => array(1, 3600, 'Atlantic/Madeira'), 'madst' => array(1, 0, 'Atlantic/Madeira'), 'madt' => array(0, -3600, 'Atlantic/Madeira'), 'magst' => array(1, 43200, 'Asia/Magadan'), 'magt' => array(0, 36000, 'Asia/Magadan'), 'malst' => array(1, 26400, 'Asia/Singapore'), 'malt' => array(0, 25200, 'Asia/Singapore'), 'malt' => array(0, 26400, 'Asia/Singapore'), 'malt' => array(0, 27000, 'Asia/Singapore'), 'mart' => array(0, -34200, 'Pacific/Marquesas'), 'mawt' => array(0, 21600, 'Antarctica/Mawson'), 'mddt' => array(1, -18000, 'America/Cambridge_Bay'), 'mdst' => array(1, 16248, 'Europe/Moscow'), 'mdt' => array(1, -21600, 'America/Denver'), 'mht' => array(0, 43200, 'Pacific/Kwajalein'), 'mmt' => array(0, 28656, 'Asia/Makassar'), 'mmt' => array(0, 9048, 'Europe/Moscow'), 'most' => array(1, 32400, 'Asia/Macao'), 'mot' => array(0, 28800, 'Asia/Macao'), 'mpt' => array(1, -21600, 'America/Denver'), 'mpt' => array(0, 36000, 'Pacific/Saipan'), 'msd' => array(1, 14400, 'Europe/Moscow'), 'msk' => array(0, 10800, 'Europe/Moscow'), 'mst' => array(0, -25200, 'America/Denver'), 'mst' => array(1, 12648, 'Europe/Moscow'), 'mut' => array(0, 14400, 'Indian/Mauritius'), 'mvt' => array(0, 18000, 'Indian/Maldives'), 'mwt' => array(1, -21600, 'America/Denver'), 'myt' => array(0, 28800, 'Asia/Kuala_Lumpur'), 'ncst' => array(1, 43200, 'Pacific/Noumea'), 'nct' => array(0, 39600, 'Pacific/Noumea'), 'nddt' => array(1, -5400, 'America/St_Johns'), 'ndt' => array(1, -36000, 'Pacific/Midway'), 'ndt' => array(1, -9000, 'America/St_Johns'), 'ndt' => array(1, -9052, 'America/St_Johns'), 'negt' => array(0, -12600, 'America/Paramaribo'), 'nest' => array(1, 4800, 'Europe/Amsterdam'), 'net' => array(0, 1200, 'Europe/Amsterdam'), 'nft' => array(0, 41400, 'Pacific/Norfolk'), 'novst' => array(1, 25200, 'Asia/Novosibirsk'), 'novt' => array(0, 21600, 'Asia/Novosibirsk'), 'npt' => array(1, -36000, 'America/Adak'), 'npt' => array(1, -9000, 'America/St_Johns'), 'npt' => array(0, 20700, 'Asia/Katmandu'), 'nrt' => array(0, 41400, 'Pacific/Nauru'), 'nrt' => array(0, 43200, 'Pacific/Nauru'), 'nst' => array(0, -12600, 'America/St_Johns'), 'nst' => array(0, -12652, 'America/St_Johns'), 'nst' => array(0, -39600, 'America/Adak'), 'nst' => array(1, 4772, 'Europe/Amsterdam'), 'nut' => array(0, -39600, 'Pacific/Niue'), 'nwt' => array(1, -9000, 'America/St_Johns'), 'nzdt' => array(1, 46800, 'Pacific/Auckland'), 'nzmt' => array(0, 41400, 'Pacific/Auckland'), 'nzst' => array(0, 43200, 'Pacific/Auckland'), 'omsst' => array(1, 21600, 'Asia/Omsk'), 'omsst' => array(1, 25200, 'Asia/Omsk'), 'omst' => array(0, 18000, 'Asia/Omsk'), 'omst' => array(0, 21600, 'Asia/Omsk'), 'orast' => array(1, 18000, 'Asia/Oral'), 'orat' => array(0, 14400, 'Asia/Oral'), 'orat' => array(0, 18000, 'Asia/Oral'), 'pddt' => array(1, -21600, 'America/Inuvik'), 'pdt' => array(1, -25200, 'America/Los_Angeles'), 'pest' => array(1, -14400, 'America/Lima'), 'petst' => array(1, 43200, 'Asia/Kamchatka'), 'petst' => array(1, 46800, 'Asia/Kamchatka'), 'pett' => array(0, 39600, 'Asia/Kamchatka'), 'pett' => array(0, 43200, 'Asia/Kamchatka'), 'pet' => array(0, -18000, 'America/Lima'), 'phot' => array(0, -39600, 'Pacific/Enderbury'), 'phot' => array(0, 46800, 'Pacific/Enderbury'), 'phst' => array(1, 32400, 'Asia/Manila'), 'pht' => array(0, 28800, 'Asia/Manila'), 'pkst' => array(1, 21600, 'Asia/Karachi'), 'pkt' => array(0, 18000, 'Asia/Karachi'), 'pmdt' => array(1, -7200, 'America/Miquelon'), 'pmst' => array(0, -10800, 'America/Miquelon'), 'pmt' => array(0, -13236, 'America/Paramaribo'), 'pmt' => array(0, -13252, 'America/Paramaribo'), 'pmt' => array(0, 26240, 'Asia/Pontianak'), 'pmt' => array(0, 36000, 'Antarctica/DumontDUrville'), 'ppt' => array(1, -25200, 'America/Los_Angeles'), 'pst' => array(0, -28800, 'America/Los_Angeles'), 'pwt' => array(1, -25200, 'America/Los_Angeles'), 'pyst' => array(1, -10800, 'America/Asuncion'), 'pyt' => array(0, -10800, 'America/Asuncion'), 'pyt' => array(0, -14400, 'America/Asuncion'), 'qyzst' => array(1, 25200, 'Asia/Qyzylorda'), 'qyzt' => array(0, 18000, 'Asia/Qyzylorda'), 'qyzt' => array(0, 21600, 'Asia/Qyzylorda'), 'ret' => array(0, 14400, 'Indian/Reunion'), 'rmt' => array(0, 5784, 'Europe/Riga'), 'rott' => array(0, -10800, 'Antarctica/Rothera'), 'sakst' => array(1, 39600, 'Asia/Sakhalin'), 'sakt' => array(0, 36000, 'Asia/Sakhalin'), 'samst' => array(1, 18000, 'Europe/Samara'), 'samst' => array(1, 21600, 'Asia/Samarkand'), 'samt' => array(0, -41400, 'Pacific/Samoa'), 'samt' => array(0, 14400, 'Asia/Samarkand'), 'samt' => array(0, 18000, 'Asia/Samarkand'), 'sast' => array(1, 10800, 'Africa/Johannesburg'), 'sast' => array(0, 7200, 'Africa/Johannesburg'), 'sbt' => array(0, 39600, 'Pacific/Guadalcanal'), 'sct' => array(0, 14400, 'Indian/Mahe'), 'sgt' => array(0, 28800, 'Asia/Singapore'), 'shest' => array(1, 21600, 'Asia/Aqtau'), 'shet' => array(0, 18000, 'Asia/Aqtau'), 'shet' => array(0, 21600, 'Asia/Aqtau'), 'slst' => array(1, -1200, 'Africa/Freetown'), 'slst' => array(1, 3600, 'Africa/Freetown'), 'smt' => array(0, 25580, 'Asia/Saigon'), 'srt' => array(0, -10800, 'America/Paramaribo'), 'sst' => array(0, -39600, 'Pacific/Samoa'), 'svest' => array(1, 18000, 'Asia/Yekaterinburg'), 'svest' => array(1, 21600, 'Asia/Yekaterinburg'), 'svet' => array(0, 14400, 'Asia/Yekaterinburg'), 'svet' => array(0, 18000, 'Asia/Yekaterinburg'), 'syot' => array(0, 10800, 'Antarctica/Syowa'), 'taht' => array(0, -36000, 'Pacific/Tahiti'), 'tasst' => array(1, 21600, 'Asia/Samarkand'), 'tasst' => array(1, 25200, 'Asia/Samarkand'), 'tast' => array(0, 18000, 'Asia/Tashkent'), 'tast' => array(0, 21600, 'Asia/Samarkand'), 'tbist' => array(1, 14400, 'Asia/Tbilisi'), 'tbist' => array(1, 18000, 'Asia/Tbilisi'), 'tbit' => array(0, 10800, 'Asia/Tbilisi'), 'tbit' => array(0, 14400, 'Asia/Tbilisi'), 'tft' => array(0, 18000, 'Indian/Kerguelen'), 'tjt' => array(0, 18000, 'Asia/Dushanbe'), 'tlt' => array(0, 28800, 'Asia/Dili'), 'tlt' => array(0, 32400, 'Asia/Dili'), 'tmt' => array(0, 12344, 'Asia/Tehran'), 'tmt' => array(0, 14400, 'Asia/Ashgabat'), 'tmt' => array(0, 18000, 'Asia/Ashgabat'), 'tmt' => array(0, 5940, 'Europe/Tallinn'), 'tost' => array(1, 50400, 'Pacific/Tongatapu'), 'tot' => array(0, 46800, 'Pacific/Tongatapu'), 'trst' => array(1, 14400, 'Europe/Istanbul'), 'trt' => array(0, 10800, 'Europe/Istanbul'), 'ulast' => array(1, 32400, 'Asia/Ulaanbaatar'), 'ulat' => array(0, 25200, 'Asia/Ulaanbaatar'), 'ulat' => array(0, 28800, 'Asia/Ulaanbaatar'), 'urast' => array(1, 18000, 'Asia/Oral'), 'urast' => array(1, 21600, 'Asia/Oral'), 'urat' => array(0, 14400, 'Asia/Oral'), 'urat' => array(0, 18000, 'Asia/Oral'), 'urat' => array(0, 21600, 'Asia/Oral'), 'urut' => array(0, 21600, 'Asia/Urumqi'), 'uyhst' => array(1, -10800, 'America/Montevideo'), 'uyhst' => array(1, -9000, 'America/Montevideo'), 'uyst' => array(1, -7200, 'America/Montevideo'), 'uyt' => array(0, -10800, 'America/Montevideo'), 'uzst' => array(1, 21600, 'Asia/Samarkand'), 'uzt' => array(0, 18000, 'Asia/Samarkand'), 'vet' => array(0, -14400, 'America/Caracas'), 'vet' => array(0, -16200, 'America/Caracas'), 'vlasst' => array(1, 36000, 'Asia/Vladivostok'), 'vlast' => array(1, 39600, 'Asia/Vladivostok'), 'vlat' => array(0, 36000, 'Asia/Vladivostok'), 'vost' => array(0, 21600, 'Antarctica/Vostok'), 'vust' => array(1, 43200, 'Pacific/Efate'), 'vut' => array(0, 39600, 'Pacific/Efate'), 'warst' => array(1, -10800, 'America/Mendoza'), 'wart' => array(0, -14400, 'America/Mendoza'), 'wast' => array(1, 7200, 'Africa/Windhoek'), 'wat' => array(0, -3600, 'Africa/Dakar'), 'wat' => array(0, 0, 'Africa/Freetown'), 'wat' => array(0, 3600, 'Africa/Brazzaville'), 'wemt' => array(1, 7200, 'Europe/Lisbon'), 'west' => array(1, 3600, 'Europe/Paris'), 'west' => array(1, 7200, 'Europe/Luxembourg'), 'wet' => array(0, 0, 'Europe/Paris'), 'wet' => array(0, 3600, 'Europe/Luxembourg'), 'wgst' => array(1, -7200, 'America/Godthab'), 'wgt' => array(0, -10800, 'America/Godthab'), 'wit' => array(0, 25200, 'Asia/Jakarta'), 'wit' => array(0, 27000, 'Asia/Jakarta'), 'wit' => array(0, 28800, 'Asia/Jakarta'), 'wst' => array(0, -39600, 'Pacific/Apia'), 'wst' => array(0, 28800, 'Australia/Perth'), 'wst' => array(1, 32400, 'Australia/Perth'), 'yakst' => array(1, 32400, 'Asia/Yakutsk'), 'yakst' => array(1, 36000, 'Asia/Yakutsk'), 'yakt' => array(0, 28800, 'Asia/Yakutsk'), 'yakt' => array(0, 32400, 'Asia/Yakutsk'), 'yddt' => array(1, -25200, 'America/Dawson'), 'ydt' => array(1, -28800, 'America/Dawson'), 'yekst' => array(1, 21600, 'Asia/Yekaterinburg'), 'yekt' => array(0, 18000, 'Asia/Yekaterinburg'), 'yerst' => array(1, 14400, 'Asia/Yerevan'), 'yerst' => array(1, 18000, 'Asia/Yerevan'), 'yert' => array(0, 10800, 'Asia/Yerevan'), 'yert' => array(0, 14400, 'Asia/Yerevan'), 'ypt' => array(1, -28800, 'America/Dawson'), 'yst' => array(0, -32400, 'America/Anchorage'), 'ywt' => array(1, -28800, 'America/Dawson'), 'zzz' => array(0, 0, 'Antarctica/Davis'));
$mapping = array();
foreach ($zones as $zone) {
    fprintf(STDERR, "Checking {$zone}: ");
    if (!(preg_match('@^([A-Z][a-z]+([_/-][A-Za-z]+)+)$@', $zone) || preg_match('@^[A-Z]{1,6}$@', $zone))) {
        fprintf(STDERR, "skipped.\n");
        continue;
    }
    $tz = @timezone_open($zone);
    if (!$tz) {
        fprintf(STDERR, "skipped.\n");
        continue;
    }
    $transistions = timezone_transitions_get($tz);
    if ($transistions === FALSE) {
        $transistions = array();
    }
    foreach ($transistions as $trans) {
        if ($trans['abbr'] == 'LMT') {
            continue;
        }
        $key = $trans['abbr'] . '|' . $trans['offset'] . '|' . ($trans['isdst'] ? '1' : '0');
        if (isset($mapping[$key])) {
            if (!in_array($zone, $mapping[$key])) {
                $mapping[$key][] = $zone;
            }
        } else {
            $mapping[$key] = array($zone);
        }
// define some classes
class classWithToString
{
    public function __toString()
    {
        return "Class A object";
    }
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
// resource
$file_handle = fopen(__FILE__, 'r');
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -12345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'string DQ' => "string", 'string SQ' => 'string', 'mixed case string' => "sTrInG", 'heredoc' => $heredoc, 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $file_handle);
foreach ($inputs as $variation => $object) {
    echo "\n-- {$variation} --\n";
    var_dump(timezone_transitions_get($object));
}
// closing the resource
fclose($file_handle);
?>
===DONE===
Exemplo n.º 7
0
function eventespresso_ddtimezone($event_id = 0)
{
    global $wpdb;
    $tz_event = $wpdb->get_var($wpdb->prepare("SELECT timezone_string FROM " . EVENTS_DETAIL_TABLE . " WHERE id = '" . $event_id . "'"));
    $timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
    $current_offset = get_option('gmt_offset');
    $tzstring = $tz_event != '' ? $tz_event : get_option('timezone_string');
    //echo $tzstring;
    $check_zone_info = true;
    // Remove old Etc mappings.  Fallback to gmt_offset.
    if (false !== strpos($tzstring, 'Etc/GMT')) {
        $tzstring = '';
    }
    if (empty($tzstring)) {
        // Create a UTC+- zone if no timezone string exists
        $check_zone_info = false;
        if (0 == $current_offset) {
            $tzstring = 'UTC+0';
        } elseif ($current_offset < 0) {
            $tzstring = 'UTC' . $current_offset;
        } else {
            $tzstring = 'UTC+' . $current_offset;
        }
    }
    ?>

    <p><select id="timezone_string" name="timezone_string">
            <?php 
    echo wp_timezone_choice($tzstring);
    ?>
        </select>
        <br />
        <span class="description"><?php 
    _e('Choose a city in the same timezone as the event.');
    ?>
</span>
    </p>

    <p><span><?php 
    printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n($timezone_format, false, 'gmt'));
    ?>
</span>
        <?php 
    if (get_option('timezone_string') || !empty($current_offset)) {
        ?>
            <br /><span><?php 
        printf(__('Local time is <code>%1$s</code>'), date_i18n($timezone_format));
        ?>
</span>
        <?php 
    }
    ?>

        <?php 
    if ($check_zone_info && $tzstring) {
        ?>
            <br />
            <span>
                <?php 
        // Set TZ so localtime works.
        date_default_timezone_set($tzstring);
        $now = localtime(time(), true);
        if ($now['tm_isdst']) {
            _e('This timezone is currently in daylight saving time.');
        } else {
            _e('This timezone is currently in standard time.');
        }
        ?>
                <br />
                <?php 
        if (function_exists('timezone_transitions_get')) {
            $found = false;
            $date_time_zone_selected = new DateTimeZone($tzstring);
            $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
            $right_now = time();
            foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
                if ($tr['ts'] > $right_now) {
                    $found = true;
                    break;
                }
            }
            if ($found) {
                echo ' ';
                $message = $tr['isdst'] ? __('Daylight saving time begins on: <code>%s</code>.') : __('Standard time begins  on: <code>%s</code>.');
                // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
                printf($message, date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $tr['ts'] + ($tz_offset - $tr['offset'])));
            } else {
                _e('This timezone does not observe daylight saving time.');
            }
        }
        // Set back to UTC.
        date_default_timezone_set('UTC');
        ?>
            </span></p>
        <?php 
    }
}
<?php

/* Prototype  : array timezone_transitions_get  ( DateTimeZone $object, [ int $timestamp_begin  [, int $timestamp_end  ]]  )
 * Description: Returns all transitions for the timezone
 * Source code: ext/date/php_date.c
 * Alias to functions: DateTimeZone::getTransitions()
 */
//Set the default time zone
date_default_timezone_set("GMT");
$tz = timezone_open("Europe/London");
echo "*** Testing timezone_transitions_get() : error conditions ***\n";
echo "\n-- Testing timezone_transitions_get() function with zero arguments --\n";
var_dump(timezone_transitions_get());
echo "\n-- Testing timezone_transitions_get() function with more than expected no. of arguments --\n";
$timestamp_begin = mktime(0, 0, 0, 1, 1, 1972);
$timestamp_end = mktime(0, 0, 0, 1, 1, 1975);
$extra_arg = 99;
var_dump(timezone_transitions_get($tz, $timestamp_begin, $timestamp_end, $extra_arg));
echo "\n-- Testing timezone_transitions_get() function with an invalid values for \$object argument --\n";
$invalid_obj = new stdClass();
var_dump(timezone_transitions_get($invalid_obj));
$invalid_obj = 10;
var_dump(timezone_transitions_get($invalid_obj));
$invalid_obj = null;
var_dump(timezone_transitions_get($invalid_obj));
?>
===DONE===
Exemplo n.º 9
0
 /**
  * Retrieve whether the timezone does have DST/non-DST mode
  *
  * @return  bool
  */
 public function hasDst()
 {
     return (bool) sizeof(timezone_transitions_get($this->tz));
 }
Exemplo n.º 10
0
	 function cets_blog_defaults_management_page(){
	 	// Display the defaults that can be set by site admins
	 
	 	global $wpdb;
		
		// only allow site admins to come here.
		if( is_super_admin() == false ) {
			wp_die( __('You do not have permission to access this page.') );
		}
		
		/* translators: date and time format for exact current time, mainly about timezones, see http://php.net/date */
		$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
		
		
		// process form submission    	
    	if (isset($_POST['action']) && $_POST['action'] == 'update') {
			$this->update_defaults($_POST);
			$updated = true;
    	}
		
		// make sure we're using latest data
		$opt = get_site_option('cets_blog_defaults_options');
		
    	if (isset($updated) && $updated) { ?>
        <div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div>
        <?php	} ?>
        
        <h1>New Blog Defaults</h1>
        <form name="blogdefaultsform" action="" method="post">
        <p>Set the defaults for new blog creation. Note that these defaults can still be over-ridden by blog owners.</p>
        <div class="wrap">
        <h2><?php _e('General Settings') ?></h2>
        <table class="form-table">
        <tr valign="top">
        <th scope="row"><?php _e('Blog Title') ?></th>
        <td><input name="blogname" type="text" id="blogname" value="<?php echo($opt['blogname']); ?>" size="40" /><br/>
        <input type="checkbox" name="blogname_flag" value="1" <?php checked('1', $opt[blogname_flag]) ?> /> <?php _e("I understand this will overwrite the user's chosen blog name from the setup page.") ?></td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('Tagline') ?></th>
        <td><input name="blogdescription" type="text" id="blogdescription" style="width: 95%" value="<?php echo($opt['blogdescription']); ?>" size="45" />
        <br />
        <?php _e('In a few words, explain what this blog is about.') ?></td>
        </tr>
		
<!-- Begin Time Zone -->
		<tr>
		<?php
		$current_offset = $opt['gmt_offset'];
		$tzstring = $opt['timezone_string'];
		
		$check_zone_info = true;
		
		// Remove old Etc mappings.  Fallback to gmt_offset.
		if ( false !== strpos($tzstring,'Etc/GMT') )
			$tzstring = '';
		
		if (empty($tzstring)) { // set the Etc zone if no timezone string exists
			$check_zone_info = false;
			if ( 0 == $current_offset )
				$tzstring = 'UTC+0';
			elseif ($current_offset < 0)
				$tzstring = 'UTC' . $current_offset;
			else
				$tzstring = 'UTC+' . $current_offset;
		}
		
		?>
		<th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
		<td>
		
		<select id="timezone_string" name="timezone_string">
		<?php echo wp_timezone_choice($tzstring); ?>
		</select>
		
		    <span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n($timezone_format, false, 'gmt')); ?></span>
		<?php if ($opt['timezone_string']) : ?>
			<span id="local-time"><?php printf(__('Local time is <code>%1$s</code>'), date_i18n($timezone_format)); ?></span>
		<?php endif; ?>
		<br />
		<span class="description"><?php _e('Choose a city in the same timezone as you.'); ?></span>
		<br />
		<span>
		<?php if ($check_zone_info && $tzstring) : ?>
			<?php
			$now = localtime(time(),true);
			if ($now['tm_isdst']) _e('This timezone is currently in daylight savings time.');
			else _e('This timezone is currently in standard time.');
			?>
			<br />
			<?php
			
			if (function_exists('timezone_transitions_get')) {
				$dateTimeZoneSelected = new DateTimeZone($tzstring);
				foreach (timezone_transitions_get($dateTimeZoneSelected) as $tr) {
					if ($tr['ts'] > time()) {
					    $found = true;
						break;
					}
				}
		
				if ( isset($found) && $found === true ) {
					echo ' ';
					$message = $tr['isdst'] ?
						__('Daylight savings time begins on: <code>%s</code>.') :
						__('Standard time begins  on: <code>%s</code>.');
					printf( $message, date_i18n($opt['date_format'].' '. $opt['time_format'], $tr['ts'] ) );
				} else {
					_e('This timezone does not observe daylight savings time.');
				}
			}
			
			?>
			</span>
		<?php endif; ?>
		</td>
		
		
		</tr>

<!-- End Time Zone -->
	
	
	
		
        <tr>
        <th scope="row"><?php _e('Date Format') ?></th>
        <td>
			<fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend>
<?php

	$date_formats = apply_filters( 'date_formats', array(
		__('F j, Y'),
		'Y/m/d',
		'm/d/Y',
		'd/m/Y',
	) );

	$custom = TRUE;

	foreach ( $date_formats as $format ) {
		echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='date_format' value='" . esc_attr($format) . "'";
		if ( $opt['date_format'] === $format ) { // checked() uses "==" rather than "==="
			echo " checked='checked'";
			$custom = FALSE;
		}
		echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
	}

	echo '	<label><input type="radio" name="date_format" id="date_format_custom_radio" value="custom"';
	checked( $custom );
	echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . esc_attr( $opt['date_format'] ) . '" class="small-text" /> ' . date_i18n( $opt['date_format'] ) . "\n";
	

	echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click &#8220;Save Changes&#8221; to update sample output.') . "</p>\n";
?>
	</fieldset>


		</td>
        </tr>
        <tr>
        <th scope="row"><?php _e('Time Format') ?></th>
        <td>
		<fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend>
		<?php
		 
			$time_formats = apply_filters( 'time_formats', array(
				__('g:i a'),
				'g:i A',
				'H:i',
			) );
		
			$custom = TRUE;
		
			foreach ( $time_formats as $format ) {
				echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='time_format' value='" . esc_attr($format) . "'";
				if ( $opt['time_format'] === $format ) { // checked() uses "==" rather than "==="
					echo " checked='checked'";
					$custom = FALSE;
				}
				echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
			}
		
			echo '	<label><input type="radio" name="time_format" id="time_format_custom_radio" value="custom"';
			checked( $custom );
			echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . esc_attr( $opt['time_format'] ) . '" class="small-text" /> ' . date_i18n( $opt['time_format'] ) . "\n";
		?>
			</fieldset>



		</td>
        </tr>
        <tr>
        <th scope="row"><?php _e('Week Starts On') ?></th>
        <td>
        
        <select name="start_of_week" id="start_of_week">
        <?php
		global $wp_locale;
        for ($day_index = 0; $day_index <= 6; $day_index++) :
            $selected = ($opt['start_of_week'] == $day_index) ? 'selected="selected"' : '';
			
            echo "\n\t<option value='$day_index' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
        endfor;
        ?>
        </select></td>
        </tr>
        </table>
        </div>
        <p>&nbsp;</p>
        <div class="wrap">
        <h2><?php _e('Writing Settings') ?></h2>
        <table class="form-table">
        <tr valign="top">
        <th scope="row"> <?php _e('Size of the post box') ?></th>
        <td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php echo($opt['default_post_edit_rows']); ?>" size="3" />
        <?php _e('lines') ?></td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('Formatting') ?></th>
        <td>
        <label for="use_smilies">
        <input name="use_smilies" type="checkbox" id="use_smilies" value="1" <?php checked('1', $opt['use_smilies']); ?> />
        <?php _e('Convert emoticons like <code>:-)</code> and <code>:-P</code> to graphics on display') ?></label><br />
        <label for="use_balanceTags"><input name="use_balanceTags" type="checkbox" id="use_balanceTags" value="1" <?php checked('1', $opt['use_balanceTags']); ?> /> <?php _e('WordPress should correct invalidly nested XHTML automatically') ?></label>
        </td>
        </tr>
        
        </table>
		
		<h3><?php _e('Remote Publishing') ?></h3>
		<p><?php printf(__('To post to WordPress from a desktop blogging client or remote website that uses the Atom Publishing Protocol or one of the XML-RPC publishing interfaces you must enable them below.')) ?></p>
		<table class="form-table">
		<tr valign="top">
		<th scope="row"><?php _e('Atom Publishing Protocol') ?></th>
		<td><fieldset><legend class="screen-reader-text"><span><?php _e('Atom Publishing Protocol') ?></span></legend>
		<label for="enable_app">
		<input name="enable_app" type="checkbox" id="enable_app" value="1" <?php checked('1', $opt['enable_app']); ?> />
		<?php _e('Enable the Atom Publishing Protocol.') ?></label><br />
		</fieldset></td>
		</tr>
		<tr valign="top">
		<th scope="row"><?php _e('XML-RPC') ?></th>
		<td><fieldset><legend class="screen-reader-text"><span><?php _e('XML-RPC') ?></span></legend>
		<label for="enable_xmlrpc">
		<input name="enable_xmlrpc" type="checkbox" id="enable_xmlrpc" value="1" <?php checked('1', $opt['enable_xmlrpc']); ?> />
		<?php _e('Enable the WordPress, Movable Type, MetaWeblog and Blogger XML-RPC publishing protocols.') ?></label><br />
		</fieldset></td>
		</tr>
		</table>
      </div>
      
      <p>&nbsp;</p>
      <div class="wrap">
        <h2><?php _e('Reading Settings') ?></h2>
        <table class="form-table">
        <tr valign="top">
        <th scope="row"><?php _e('Blog pages show at most') ?></th>
        <td>
        <input name="posts_per_page" type="text" id="posts_per_page" value="<?php echo($opt['posts_per_page']); ?>" size="3" /> <?php _e('posts') ?>
        </td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('Syndication feeds show the most recent') ?></th>
        <td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php echo($opt['posts_per_rss']); ?>" size="3" /> <?php _e('posts') ?></td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('For each article in a feed, show') ?> </th>
        <td>
        <p><label><input name="rss_use_excerpt"  type="radio" value="0" <?php checked(0, $opt['rss_use_excerpt']); ?>	/> <?php _e('Full text') ?></label><br />
        <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, $opt['rss_use_excerpt']); ?> /> <?php _e('Summary') ?></label></p>
        </td>
        </tr>
        
        <tr valign="top">
        <th scope="row"><?php _e('Encoding for pages and feeds') ?></th>
        <td><input name="blog_charset" type="text" id="blog_charset" value="<?php echo($opt['blog_charset']); ?>" size="20" class="code" /><br />
        <?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></td>
        </tr>
        </table>
        
        </div>
        
        
        <p>&nbsp;</p>
        <div class="wrap">     
    	<h2>Discussion Settings</h2>
        <table class="form-table">
        <tr valign="top">
        <th scope="row"><?php _e('Default article settings') ?></th>
        <td>
         <label for="default_pingback_flag">
		 
       <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php  if ($opt['default_pingback_flag'] == 1) echo('checked="checked"'); ?> /> <?php _e('Attempt to notify any blogs linked to from the article (slows down posting.)') ?> </label>
       
        <br /> 
		<label for="default_ping_status">
		
        <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php if ($opt['default_ping_status'] == 'open') echo('checked="checked"'); ?> /> <?php _e('Allow link notifications from other blogs (pingbacks and trackbacks.)') ?></label>
       
        <br />
        <label for="default_comment_status">
		
        <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php if ($opt['default_comment_status'] == 'open') echo('checked="checked"'); ?> /> <?php _e('Allow people to post comments on the article') ?></label>
    
        <br />
        <small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small>
        </td>
        </tr>
		<tr valign="top">
		<th scope="row"><?php _e('Other comment settings') ?></th>
		<td><fieldset><legend class="hidden"><?php _e('Other comment settings') ?></legend>
		
		<label for="require_name_email">
		
        <input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php if ($opt['require_name_email'] == 1) echo('checked="checked"'); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label>
		<br />
		<label for="comment_registration">
		<input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', $opt['comment_registration']); ?> />
		<?php _e('Users must be registered and logged in to comment') ?>
		</label>
		<br />
		
		<label for="close_comments_for_old_posts">
		<input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', $opt['close_comments_for_old_posts']); ?> />
		<?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . esc_attr($opt['close_comments_days_old']) . '" class="small-text" />') ?>
		<br />
		<label for="thread_comments">
		<input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', $opt['thread_comments']); ?> />
		<?php
		
		$maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
		
		
		
		$thread_comments_depth = '</label><select name="thread_comments_depth" id="thread_comments_depth">';
		for ( $i = 1; $i <= $maxdeep; $i++ ) {
			$thread_comments_depth .= "<option value='$i'";
			if (isset($opt['thread_comments_depth']) && $opt['thread_comments_depth'] == $i ) $thread_comments_depth .= " selected='selected'";
			$thread_comments_depth .= ">$i</option>";
		}
		$thread_comments_depth .= '</select>';
		
		printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
		
		?><br />
		<label for="page_comments">
		<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', $opt['page_comments']); ?> />
		<?php
		
		
		$default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
		if ( isset($opt['default_comments_page']) && 'newest' == $opt['default_comments_page'] ) $default_comments_page .= ' selected="selected"';
		$default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
		if ( 'oldest' == $opt['default_comments_page'] ) $default_comments_page .= ' selected="selected"';
		$default_comments_page .= '>' . __('first') . '</option></select>';
		
		printf( __('Break comments into pages with %1$s comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . esc_attr($opt['comments_per_page']) . '" class="small-text" />', $default_comments_page );
		
		?></label>
		<br />
		<label for="comment_order"><?php
		
		$comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
		if ( 'asc' == $opt['comment_order'] ) $comment_order .= ' selected="selected"';
		$comment_order .= '>' . __('older') . '</option><option value="desc"';
		if ( 'desc' == $opt['comment_order'] ) $comment_order .= ' selected="selected"';
		$comment_order .= '>' . __('newer') . '</option></select>';
		
		printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order );
		
		?></label>
		</fieldset></td>
		</tr>
		
		
		
		
        <tr valign="top">
        <th scope="row"><?php _e('E-mail me whenever') ?></th>
        <td>
		<label for="comments_notify">
		
        <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php if ($opt['comments_notify'] == 1 ) echo('checked="checked"'); ?> /> <?php _e('Anyone posts a comment') ?> </label>
         
        <br />
		<label for="moderation_notify">
		
        <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php if ($opt['moderation_notify'] == 1) echo('checked="checked"'); ?> /> <?php _e('A comment is held for moderation') ?></label>
        </td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('Before a comment appears') ?></th>
        <td>
		<label for="comment_moderation">
		
        <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php if ($opt['comment_moderation'] == 1) echo('checked="checked"'); ?> /> <?php _e('An administrator must always approve the comment') ?></label>
    
        
        
        <br />
		<label for="comment_whitelist">
        <input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php if ($opt['comment_whitelist'] == 1) echo('checked="checked"'); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label>
       
        </td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('Comment Moderation') ?></th>
        <td>
        <p><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" size="3" value="' . $opt['comment_max_links']. '" />' ) ?></p>
        
        <p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p>
        <p>
        <textarea name="moderation_keys" cols="60" rows="10" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php echo($opt['moderation_keys']); ?></textarea>
        </p>
        </td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('Comment Blacklist') ?></th>
        <td>
        <p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p>
        <p>
        <textarea name="blacklist_keys" cols="60" rows="10" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php echo($opt['blacklist_keys']); ?></textarea>
        </p>
        </td>
        </tr>
        </table>
        
        <h3><?php _e('Avatars') ?></h3>

        <p><?php _e('By default WordPress uses <a href="http://gravatar.com/">Gravatars</a> &#8212; short for Globally Recognized Avatars &#8212; for the pictures that show up next to comments. Plugins may override this.'); ?></p>
        
        <?php // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that? ?>
        
        <table class="form-table">
        <tr valign="top">
        <th scope="row"><?php _e('Avatar display') ?></th>
        <td>
        <?php
            $yesorno = array(0 => __("Don&#8217;t show Avatars"), 1 => __('Show Avatars'));
            foreach ( $yesorno as $key => $value) {
                $selected = ($opt['show_avatars'] == $key) ? 'checked="checked"' : '';
                echo "\n\t<label><input type='radio' name='show_avatars' value='$key' $selected> $value</label><br />";
            }
        ?>
        </td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('Maximum Rating') ?></th>
        <td>
        
        <?php
        $ratings = array( 'G' => __('G &#8212; Suitable for all audiences'), 'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above'), 'R' => __('R &#8212; Intended for adult audiences above 17'), 'X' => __('X &#8212; Even more mature than above'));
        foreach ($ratings as $key => $rating) :
          	$selected = ($opt['avatar_rating'] == $key) ? 'checked="checked"' : '';
            echo "\n\t<label><input type='radio' name='avatar_rating' value='$key' $selected> $rating</label><br />";
        endforeach;
        ?>
        
        </td>
        </tr>
		
		
		
		<tr valign="top">
		<th scope="row"><?php _e('Default Avatar') ?></th>
		<td class="defaultavatarpicker"><fieldset><legend class="hidden"><?php _e('Default Avatar') ?></legend>
		
		<?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
		
		<?php
		$avatar_defaults = array(
			'mystery' => __('Mystery Man'),
			'blank' => __('Blank'),
			'gravatar_default' => __('Gravatar Logo'),
			'identicon' => __('Identicon (Generated)'),
			'wavatar' => __('Wavatar (Generated)'),
			'monsterid' => __('MonsterID (Generated)')
		);
		$avatar_defaults = apply_filters('avatar_defaults', $avatar_defaults);
		$default = $opt['avatar_default'];
		if ( empty($default) )
			$default = 'mystery';
		$size = 32;
		$avatar_list = '';
		foreach ( $avatar_defaults as $default_key => $default_name ) {
			$selected = ($default == $default_key) ? 'checked="checked" ' : '';
			$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='{$default_key}' {$selected}/> ";
		
			//$avatar = get_avatar( $user_email, $size, $default_key );
			//$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&amp;forcedefault=1'", $avatar);
		
			$avatar_list .= ' ' . $default_name . '</label>';
			$avatar_list .= '<br />';
		}
		echo apply_filters('default_avatar_select', $avatar_list);
		?>
		
		</fieldset></td>
		</tr>
		
		
        
        </table>

        </div>
        <p>&nbsp;</p>
        <div class="wrap">
        <h2><?php _e('Privacy Settings') ?></h2>
        <table class="form-table">
        <tr valign="top">
        <th scope="row"><?php _e('Blog Visibility') ?> </th>
        <td>
        <p>Warning: It can be confusing for users to have these settings override the setting they choose on the sign up form. If you do not want to override user settings, select "Allow User Choice".</p>
		
		<p><input id="blog-public-reset" type="radio" name="blog_public" value="" <?php checked('', $opt['blog_public']); ?> />
        <label for="blog-public-reset"><?php _e('Allow User Choice'); ?></label></p>
        <p><input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', $opt['blog_public']); ?> />
        <label for="blog-public"><?php _e('I would like my blog to be visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers and in public listings around this site.') ?></label></p>
        <p><input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', $opt['blog_public']); ?> />
        <label for="blog-norobots"><?php _e('I would like to block search engines, but allow normal visitors'); ?></label></p>
        <?php do_action('blog_privacy_selector'); ?>
        </td>
        </tr>
        </table>
        
       
        </div>
        <p>&nbsp;</p>
		<div class="wrap">
        <h2><?php _e('Customize Permalink Structure') ?></h2>
        <p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
        
        <?php
        $prefix = '';
        
        if ( ! got_mod_rewrite() )
            $prefix = '/index.php';
        
        $structures = array(
            '',
            $prefix . '/%year%/%monthnum%/%day%/%postname%/',
            $prefix . '/%year%/%monthnum%/%postname%/',
            $prefix . '/archives/%post_id%'
            );
        ?>
        <h3><?php _e('Common settings'); ?></h3>
        
        <table class="form-table">
            <tr>
                <th><label><input name="permalink_choice" type="radio" value="" class="tog" <?php checked('', $opt['permalink_structure']); ?> /> <?php _e('Default'); ?></label></th>
                <td>&nbsp;</td>
             </tr>
            <tr>
                <th><label><input name="permalink_choice" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $opt['permalink_structure']); ?> /> <?php _e('Day and name'); ?></label></th>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <th><label><input name="permalink_choice" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $opt['permalink_structure']); ?> /> <?php _e('Month and name'); ?></label></th>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <th><label><input name="permalink_choice" type="radio" value="<?php echo $structures[3]; ?>" class="tog" <?php checked($structures[3], $opt['permalink_structure']); ?> /> <?php _e('Numeric'); ?></label></th>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <th>
                    <label><input name="permalink_choice" id="custom_selection" type="radio" value="custom" class="tog"
                    <?php if ( !in_array($opt['permalink_structure'], $structures) ) { ?>
                    checked="checked"
                    <?php } ?>
                     />
                    <?php _e('Custom Structure'); ?>
                    </label>
                </th>
                <td>
                    <?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $permalink_structure = str_replace( "/blog", "", $opt['permalink_structure'] ); }?>
                    <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo esc_attr($opt['permalink_structure']); ?>" size="50" />
                </td>
            </tr>
        </table>
        
        <h3><?php _e('Optional'); ?></h3>
        <?php if ($is_apache) : ?>
            <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>/topics/</code> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
        <?php else : ?>
            <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>/topics/</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
        <?php endif; ?>
        
        <table class="form-table">
            <tr>
                <th><?php _e('Category base'); ?></th>
                <td><?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $opt['category_base'] = str_replace( "/blog", "", $opt['category_base'] ); }?> <input name="category_base" type="text" class="code"  value="<?php echo esc_attr( $opt['category_base'] ); ?>" size="30" /></td>
            </tr>
            <tr>
                <th><?php _e('Tag base'); ?></th>
                <td><?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $opt['tag_base'] = str_replace( "/blog", "", $opt['tag_base'] ); }?> <input name="tag_base" id="tag_base" type="text" class="code"  value="<?php echo esc_attr($opt['tag_base']); ?>" size="30" /></td>
            </tr>
        </table>
        
        </div>
                
        
        <p>&nbsp;</p>
        
        <div class="wrap">
        <h2><?php _e('Media Settings'); ?></h2>
        <h3><?php _e('Image sizes') ?></h3>
        <p><?php _e('The sizes listed below determine the maximum dimensions to use when inserting an image into the body of a post.'); ?></p>
        
        <table class="form-table">
        <tr valign="top">
        <th scope="row"><?php _e('Thumbnail size') ?></th>
        <td>
        <label for="thumbnail_size_w"><?php _e('Width'); ?></label>
        <input name="thumbnail_size_w" type="text" id="thumbnail_size_w" value="<?php echo($opt['thumbnail_size_w']); ?>" size="6" />
        <label for="thumbnail_size_h"><?php _e('Height'); ?></label>
        <input name="thumbnail_size_h" type="text" id="thumbnail_size_h" value="<?php echo($opt['thumbnail_size_h']); ?>" size="6" /><br />
        <input name="thumbnail_crop" type="checkbox" id="thumbnail_crop" value="1" <?php checked('1', $opt['thumbnail_crop']); ?>/>
        <label for="thumbnail_crop"><?php _e('Crop thumbnail to exact dimensions (normally thumbnails are proportional)'); ?></label>
        </td>
        </tr>
        <tr valign="top">
        <th scope="row"><?php _e('Medium size') ?></th>
        <td>
        <label for="medium_size_w"><?php _e('Max Width'); ?></label>
        <input name="medium_size_w" type="text" id="medium_size_w" value="<?php echo($opt['medium_size_w']); ?>" size="6" />
        <label for="medium_size_h"><?php _e('Max Height'); ?></label>
        <input name="medium_size_h" type="text" id="medium_size_h" value="<?php echo($opt['medium_size_h']); ?>" size="6" />
        </td>
        </tr>
			<tr valign="top">
		<th scope="row"><?php _e('Large size') ?></th>
		<td><fieldset><legend class="hidden"><?php _e('Large size') ?></legend>
		<label for="large_size_w"><?php _e('Max Width'); ?></label>
		<input name="large_size_w" type="text" id="large_size_w" value="<?php echo($opt['large_size_w']); ?>" class="small-text" />
		<label for="large_size_h"><?php _e('Max Height'); ?></label>
		<input name="large_size_h" type="text" id="large_size_h" value="<?php echo($opt['large_size_h']); ?>" class="small-text" />
		</fieldset></td>
		</tr>
		</table>
        <h3><?php _e('Embeds') ?></h3>

		<table class="form-table">
		
		<tr valign="top">
		<th scope="row"><?php _e('Auto-embeds'); ?></th>
		<td><fieldset><legend class="screen-reader-text"><span><?php _e('Attempt to automatically embed all plain text URLs'); ?></span></legend>
		<label for="embed_autourls"><input name="embed_autourls" type="checkbox" id="embed_autourls" value="1" <?php checked( '1', $opt['embed_autourls'] ); ?>/> <?php _e('Attempt to automatically embed all plain text URLs'); ?></label>
		</fieldset></td>
		</tr>
		
		<tr valign="top">
		<th scope="row"><?php _e('Maximum embed size') ?></th>
		<td>
		<label for="embed_size_w"><?php _e('Width'); ?></label>
		<input name="embed_size_w" type="text" id="embed_size_w" value="<?php echo $opt['embed_size_w']; ?>" class="small-text" />
		<label for="embed_size_h"><?php _e('Height'); ?></label>
		<input name="embed_size_h" type="text" id="embed_size_h" value="<?php echo $opt['embed_size_h']; ?>" class="small-text" />
		<?php if ( !empty($content_width) ) echo '<br />' . __("If the width value is left blank, embeds will default to the max width of your theme."); ?>
		</td>
		</tr>
		
		
		</table>
        </div>
        <p>&nbsp;</p>
        <div class="wrap">
        <h2>Default Theme</h2>
        <?php 
		$themes = get_themes();
		$ct = current_theme_info();
		$allowed_themes = get_site_allowed_themes();
		if( $allowed_themes == false )
			$allowed_themes = array();
		
		$blog_allowed_themes = wpmu_get_blog_allowedthemes();
		if( is_array( $blog_allowed_themes ) )
			$allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes );
		
		if( $blog_id != 1 ) {
			unset( $allowed_themes[ "h3" ] );
		}
		
		if( isset( $allowed_themes[ esc_html( $ct->stylesheet ) ] ) == false )
			$allowed_themes[ esc_html( $ct->stylesheet ) ] = true;
		
		reset( $themes );
		foreach( $themes as $key => $theme ) {
			if( isset( $allowed_themes[ esc_html( $theme[ 'Stylesheet' ] ) ] ) == false ) {
				unset( $themes[ $key ] );
			}
		}
		reset( $themes );
		
		// get the names of the themes & sort them
		$theme_names = array_keys($themes);
		natcasesort($theme_names);
		?>
        <table class="form-table">
        <tr valign="top">
        <th>Select the default theme:</th>
        <td><select name="theme" size="1">
        <?php
		foreach ($theme_names as $theme_name) {
		$template = $themes[$theme_name]['Template'];
		$stylesheet = $themes[$theme_name]['Stylesheet'];
		$title = $themes[$theme_name]['Title'];
		$selected = "";
		if($opt[theme] == $template . "|" . $stylesheet) {
			$selected = "selected = 'selected' ";
		}
		echo('<option value="' . $template . "|" . $stylesheet .  '"' . $selected . '>' . $title . "</option>");
		}
		?>
        </select>
        </td>
        </tr>
        </table>
        </div>
        
        <div class="wrap">
        <h2>Bonus Settings</h2>
		<table class="form-table">
        <tr valign="top">
        <th>From Email:</th>
		<td><input name="from_email" type="text" id="from_email" size="30" value="<?php echo($opt['from_email']); ?>"  /></td>
		</tr>
		  <tr valign="top">
        <th>From Email Name:<br/>(defaults to site name if left blank)</th>
		<td><input name="from_email_name" type="text" id="from_email_name" size="30" value="<?php echo($opt['from_email_name']); ?>"  /></td>
		</tr>
		<tr>
			<th>Delete Standard WordPress Blogroll Links</th>
			<td>
		<label for="delete_blogroll_links">
		
        <input name="delete_blogroll_links" type="checkbox" id="delete_blogroll_links" value="1" <?php if ($opt['delete_blogroll_links'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?></label>
		</td>
		</tr>
		<tr valign="top">
        <th>Default Link Category:<br/> (Overwrites "Blogroll")</th>
		<td><input name="default_link_cat" type="text" id="default_link_cat" size="30" value="<?php echo($opt['default_link_cat']); ?>"  /></td>
		</tr>
		<tr valign="top">
        <th scope="row"><?php _e('Additional Links') ?></th>
        <td>
        <p><?php _e('Enter links one per line with the name followed by an equals sign and a greater than sign and then the fully qualified link. Example: Google=>http://www.google.com') ?></p>
        <p>
        <textarea name="default_links" cols="60" rows="10" id="default_links" style="width: 98%; font-size: 12px;" class="code"><?php echo(str_replace('|+', "\n", $opt['default_links'])); ?></textarea>
        </p>
        </td>
        </tr>
		
		<tr valign="top">
        <th>Default Category:<br/> (Overwrites "Uncategorized")</th>
		<td><input name="default_cat_name" type="text" id="default_cat_name" size="30" value="<?php echo($opt['default_cat_name']); ?>"  /></td>
		</tr>
		<tr valign="top">
        <th scope="row"><?php _e('Additional Categories') ?></th>
        <td>
        <p><?php _e('Enter categories one per line with the name followed by an equals sign and a greater than sign and then the description => Nice Name => parent name. Example: Plugins=>Find out out about my plugins=>plugins=>code') ?></p>
        <p>
        <textarea name="default_categories" cols="60" rows="10" id="default_categories" style="width: 98%; font-size: 12px;" class="code"><?php echo(str_replace('|+', "\n", $opt['default_categories'])); ?></textarea>
        </p>
        </td>
        </tr>
		
    	<tr>
			<th>Delete Initial Comment</th>
			<td>
		<label for="delete_first_comment">
		
        <input name="delete_first_comment" type="checkbox" id="delete_first_comment" value="1" <?php if ($opt['delete_first_comment'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?></label>
		</td>
		</tr>
		<tr>
			<th>Close Comments on Hello World Post</th>
			<td>
		<label for="close_comments_on_hello_world">
		
        <input name="close_comments_on_hello_world" type="checkbox" id="close_comments_on_hello_world" value="1" <?php if ($opt['close_comments_on_hello_world'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?></label>
		</td>
		</tr>
		<tr>
			<th>Close Comments on About Page</th>
			<td>
		<label for="close_comments_on_about_page">
		
        <input name="close_comments_on_about_page" type="checkbox" id="close_comments_on_about_page" value="1" <?php if ($opt['close_comments_on_about_page'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?></label>
		</td>
		</tr>
		<tr>
			<th>Make First Post a Draft ("Hello World")</th>
			<td>
		<label for="delete_first_post">
		
        <input name="delete_first_post" type="checkbox" id="delete_first_post" value="1" <?php if ($opt['delete_first_post'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?></label>
		</td>
		</tr>
		
		<tr>
			<th>Delete Initial Widgets</th>
			<td>
			<input name="delete_initial_widgets" type="checkbox" id="delete_initial_widgets" value="1" <?php if ($opt['delete_initial_widgets'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?>
			</td>
		</tr>
		
		<tr>
			<th colspan="2">
				Sites that use a combination of BBPress and BuddyPress need all users to be subscribed to the blog on which BBPress is installed. The following section lets you do that. Note that you may add people to a comma-delimited list of blogs, but they will have the same role on each blog. 
			</td>
		</tr>
		<tr valign="top">
        <th>Add User to Other Blog(s):</th>
		<td><input name="add_user_to_blog" type="checkbox" id="add_user_to_blog" value="1" <?php if ($opt['add_user_to_blog'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?></label>
		</td>
		</tr>
		<tr valign="top">
        <th>Role on Other Blog (s)</th>
		<td>
			<select name="add_user_to_blog_role" id="add_user_to_blog_role">
			<option value="administrator"<?php if($opt['add_user_to_blog_role'] == 'administrator') echo ' selected="selected"';?>>Administator</option>
			<option value="editor"<?php if($opt['add_user_to_blog_role'] == 'editor') echo ' selected="selected"';?>>Editor</option>
			<option value="author"<?php if($opt['add_user_to_blog_role'] == 'author') echo ' selected="selected"';?>>Author</option>
			<option value="contributor"<?php if($opt['add_user_to_blog_role'] == 'contributor') echo ' selected="selected"';?>>Contributor</option>
			<option value="subscriber"<?php if($opt['add_user_to_blog_role'] == 'subscriber') echo ' selected="selected"';?>>Subscriber</option>				
		</select></td>
		</tr>
		<tr valign="top">
        <th>Blog ID's to add User To:</th>
		<td><input name="add_user_to_blog_id" type="text" id="add_user_to_blog_id" size="30" value="<?php echo($opt['add_user_to_blog_id']); ?>"  /><br/>Use Blog ID or comma-delimited list of ID's.</td>
		</tr>
		</table>
		</div>
        
        
         <p>  
         <input type="hidden" name="action" value="update" />
        <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
          </p> 
        
        <?php
	 }
Exemplo n.º 11
0
 /**
  * @param string|DateTimeInterface $value
  * @param DateTimeZone             $timeZone
  * @param string                   $message
  */
 public static function isDayLightSavingTime($value, DateTimeZone $timeZone, $message = '')
 {
     $value = self::convertToDateTime($value);
     $transitions = timezone_transitions_get($timeZone, $value->getTimestamp(), $value->getTimestamp());
     if (is_array($transitions) && !empty($transitions)) {
         foreach ($transitions as $transition) {
             if (0 == $transition['isdst']) {
                 throw new AssertionException($message ? $message : self::ASSERT_IS_DST);
             }
         }
     }
 }
    {
        return "Class A object";
    }
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
// resource
$file_handle = fopen(__FILE__, 'r');
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -12345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'string DQ' => "string", 'string SQ' => 'string', 'mixed case string' => "sTrInG", 'heredoc' => $heredoc, 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $file_handle);
$tz = timezone_open("Europe/London");
$timestamp_end = mktime(0, 0, 0, 1, 1, 1975);
foreach ($inputs as $variation => $timestamp_begin) {
    echo "\n-- {$variation} --\n";
    $tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end);
    var_dump(gettype($tran));
    var_dump(count($tran));
}
// closing the resource
fclose($file_handle);
?>
===DONE===
<?php

/* Prototype  : array timezone_transitions_get  ( DateTimeZone $object, [ int $timestamp_begin  [, int $timestamp_end  ]]  )
 * Description: Returns all transitions for the timezone
 * Source code: ext/date/php_date.c
 * Alias to functions: DateTimeZone::getTransitions()
 */
echo "*** Testing timezone_transitions_get() : basic functionality ***\n";
//Set the default time zone
date_default_timezone_set("Europe/London");
// Create a DateTimeZone object
$tz = timezone_open("Europe/London");
$tran = timezone_transitions_get($tz);
echo "\n-- Get all 60s transitions --\n";
$tran = timezone_transitions_get($tz, -306972000, -37241999);
var_dump(gettype($tran));
echo "\n-- Total number of transitions: " . count($tran) . " --\n";
echo "\n-- Format a sample entry pfor Spring 1963 --\n";
var_dump($tran[6]);
?>
===DONE===
Exemplo n.º 14
0
<?php 
    if ($tzstring) {
        ?>
	<?php 
        $now = localtime(time(), true);
        if ($now['tm_isdst']) {
            _e('This timezone is currently in daylight savings time.');
        } else {
            _e('This timezone is currently in standard time.');
        }
        ?>
	<br />
	<?php 
        if (function_exists('timezone_transitions_get')) {
            $dateTimeZoneSelected = new DateTimeZone($tzstring);
            foreach (timezone_transitions_get($dateTimeZoneSelected) as $tr) {
                if ($tr['ts'] > time()) {
                    $found = true;
                    break;
                }
            }
            if (isset($found) && $found === true) {
                echo ' ';
                $message = $tr['isdst'] ? __('Daylight savings time begins on: <code>%s</code>.') : __('Standard time begins  on: <code>%s</code>.');
                printf($message, date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $tr['ts']));
            } else {
                _e('This timezone does not observe daylight savings time.');
            }
        }
        ?>
	</span>
Exemplo n.º 15
0
            $timezone_string = 'Etc/GMT+' . abs($_gmt_offset);
        }
        unset($_gmt_offset);
    }
    // Build the new selector
    $_time_options = array('timezone_string' => array('title' => __('Time zone'), 'type' => 'select', 'options' => wp_timezone_choice($timezone_string), 'note' => array(__('Choose a city in the same time zone as you.'), sprintf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), bb_gmdate_i18n(bb_get_datetime_formatstring_i18n(), bb_current_time())), sprintf(__('Local time is <code>%s</code>'), bb_datetime_format_i18n(bb_current_time())))));
    $_now = localtime(bb_current_time(), true);
    if ($now['tm_isdst']) {
        $_time_options['timezone_string']['note'][] = __('This time zone is currently in daylight savings time.');
    } else {
        $_time_options['timezone_string']['note'][] = __('This time zone is currently in standard time.');
    }
    if (function_exists('timezone_transitions_get')) {
        $timezone_object = new DateTimeZone($timezone_string);
        $found_transition = false;
        foreach (timezone_transitions_get($timezone_object) as $timezone_transition) {
            if ($timezone_transition['ts'] > time()) {
                $note = $timezone_transition['isdst'] ? __('Daylight savings time begins on <code>%s</code>') : __('Standard time begins on <code>%s</code>');
                $_time_options['timezone_string']['note'][] = sprintf($note, bb_gmdate_i18n(bb_get_datetime_formatstring_i18n(), $timezone_transition['ts'], false));
                break;
            }
        }
    }
    $time_options = array_merge($_time_options, $time_options);
} else {
    // Tidy up the old style dropdown
    $time_options['gmt_offset']['note'] = array(1 => sprintf(__('<abbr title="Coordinated Universal Time">UTC</abbr> %s is <code>%s</code>'), $time_options['gmt_offset']['options'][$gmt_offset], bb_datetime_format_i18n(bb_current_time())), 2 => __('Unfortunately, you have to manually update this for Daylight Savings Time.'));
    if ($gmt_offset) {
        $time_options['gmt_offset']['note'][0] = sprintf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), bb_gmdate_i18n(bb_get_datetime_formatstring_i18n(), bb_current_time(), true));
        ksort($time_options['gmt_offset']['note']);
    }
    $now = localtime(time(), true);
    if ($now['tm_isdst']) {
        _e('This timezone is currently in daylight saving time.');
    } else {
        _e('This timezone is currently in standard time.');
    }
    ?>
	<br />
	<?php 
    $allowed_zones = timezone_identifiers_list();
    if (in_array($tzstring, $allowed_zones)) {
        $found = false;
        $date_time_zone_selected = new DateTimeZone($tzstring);
        $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
        $right_now = time();
        foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
            if ($tr['ts'] > $right_now) {
                $found = true;
                break;
            }
        }
        if ($found) {
            echo ' ';
            $message = $tr['isdst'] ? __('Daylight saving time begins on: <code>%s</code>.') : __('Standard time begins on: <code>%s</code>.');
            // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
            printf($message, date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $tr['ts'] + ($tz_offset - $tr['offset'])));
        } else {
            _e('This timezone does not observe daylight saving time.');
        }
    }
    // Set back to UTC.
Exemplo n.º 17
0
function amr_check_timezonesettings()
{
    global $amr_globaltz;
    echo '<ul>';
    if (function_exists('timezone_version_get')) {
        printf('<li>' . __('Your timezone db version is: %s', 'amr-ical-events-list') . '</li>', timezone_version_get());
    } else {
        echo '<li>' . '<a href="http://en.wikipedia.org/wiki/Tz_database">' . __('Plugin cannot determine timezonedb version in php &lt; 5.3.', 'amr-ical-events-list') . '</a>';
    }
    echo '</li></li><li><a href="http://pecl.php.net/package/timezonedb">';
    _e('Php timezonedb versions', 'amr-ical-events-list');
    echo '</a> &nbsp; <a href="http://pecl.php.net/package/timezonedb">';
    _e('Info on what changes are in which timezonedb version', 'amr-ical-events-list');
    echo '</a></li>';
    if (!isset($amr_globaltz)) {
        echo '<b>' . __('No global timezone - is there a problem here? ', 'amr-ical-events-list') . '</b>';
        return;
    }
    $tz = get_option('timezone_string');
    $settingslink = '<a href="' . get_option('siteurl') . '/wp-admin/options-general.php">' . __('Go to settings', 'amr-ical-events-list') . '</a>';
    if ($tz == '') {
        $gmtoffset = get_option('gmt_offset');
        if (!empty($gmtoffset)) {
            printf('<li style="color: red;"><b>' . __('You are using the "old" gmt_offset setting ', 'amr-ical-events-list') . '</b></li><li>', $gmtoffset);
            _e('Consider changing to the more accurate timezone setting', 'amr-ical-events-list');
            echo '</li>';
        }
    }
    $now = date_create('now', $amr_globaltz);
    echo '<li>' . __('The plugin thinks your timezone is: ', 'amr-ical-events-list') . timezone_name_get($amr_globaltz) . '&nbsp;' . $settingslink . '</li>' . '<li>' . __('The current UTC offset for that timezone is: ', 'amr-ical-events-list') . $now->getoffset() / (60 * 60) . '</li>';
    if (function_exists('timezone_transitions_get')) {
        foreach (timezone_transitions_get($amr_globaltz) as $tr) {
            if ($tr['ts'] > time()) {
                break;
            }
        }
    }
    $utctz = new DateTimeZone('UTC');
    if (isset($tr['ts'])) {
        $d = amr_create_date_time("@{$tr['ts']}", $utctz);
        //try {$d = new DateTime( "@{$tr['ts']}",$utctz );}
        //catch(Exception $e) { break;}
        date_timezone_set($d, $amr_globaltz);
        printf('<li>' . __('Switches to %s on %s. GMT offset: %d', 'amr-ical-events-list') . '</li>', $tr['isdst'] ? "DST" : "standard time", $d->format('d M Y @ H:i'), $tr['offset'] / (60 * 60));
    }
    echo '<li>';
    _e('Current time (unlocalised): ', 'amr-ical-events-list');
    echo $now->format('r');
    echo '</li></ul>';
}