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);
}