Example #1
0
function set_timezone($lang = '')
{
    if (empty($lang)) {
        return array('UTC', 0);
    }
    $l = accept_language::split_locale_str($lang);
    // When the name of a country is uncertain (国名が不明な場合)
    if (empty($l[2])) {
        $obj_l2c = new lang2country();
        $l[2] = $obj_l2c->get_lang2country($l[1]);
        if (empty($l[2])) {
            return array('UTC', 0);
        }
    }
    $obj = new timezone();
    $obj->set_datetime(UTIME);
    // Setting at judgment time. (判定時刻の設定)
    $obj->set_country($l[2]);
    // The acquisition country is specified. (取得国を指定)
    // With the installation country in case of the same
    // 設置者の国と同一の場合
    if ($lang == DEFAULT_LANG) {
        if (defined('DEFAULT_TZ_NAME')) {
            $obj->set_tz_name(DEFAULT_TZ_NAME);
        }
    }
    list($zone, $zonetime) = $obj->get_zonetime();
    if ($zonetime == 0 || empty($zone)) {
        return array('UTC', 0);
    }
    return array($zone, $zonetime);
}
/**
 * World Time プラグイン
 *
 * @copyright   Copyright &copy; 2005-2006, Katsumi Saito <*****@*****.**>
 * @version     $Id: worldtime.inc.php,v 0.4 2006/02/16 01:31:00 upk Exp $
 *
 */
function plugin_worldtime_inline()
{
    switch (func_num_args()) {
        case 1:
            return "&worldtime( timezone_name ){format};\n";
        default:
            list($code, $format) = func_get_args();
            $format = htmlspecialchars($format, ENT_QUOTES);
    }
    if (empty($code)) {
        return '';
    }
    $obj = new timezone();
    $obj->set_datetime();
    $obj->set_tz_name($code);
    list($zone, $zonetime) = $obj->get_zonetime();
    if (empty($format)) {
        $format = 'Y-m-d H:i T';
    }
    $x = gmdate($format, UTIME + $zonetime);
    $x = str_replace('GMT', $zone, $x);
    return $x;
}