• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_user_timezone_offset函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_user_timezone_offset函数的典型用法代码示例。如果您正苦于以下问题:PHP get_user_timezone_offset函数的具体用法?PHP get_user_timezone_offset怎么用?PHP get_user_timezone_offset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_user_timezone_offset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: test_pm_gmt_from_usertime

 /**
  * Test pm_gmt_from_usertime() function
  * @param int $intimestamp the input timestamp
  * @param float|int|string $timezone the timezone of $intimestamp
  * @param int $outtimestamp the GMT timestamp for $intimestamp in $timezone
  * @dataProvider pm_gmt_from_usertime_dataprovider
  */
 public function test_pm_gmt_from_usertime($intimestamp, $timezone, $outtimestamp)
 {
     if (get_user_timezone_offset($timezone) == 99) {
         $this->markTestSkipped("\nSkipping test_pm_gmt_from_usertime() with undefined timezone = '{$timezone}'\n");
     } else {
         $this->assertEquals($outtimestamp, pm_gmt_from_usertime($intimestamp, $timezone));
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:15,代码来源:pm_gmt_from_usertime_test.php


示例2: get_end_time

 function get_end_time()
 {
     if ($this->endtimehour >= 25 || $this->endtimeminute >= 61) {
         return 0;
     }
     $endtime = ($this->endtimehour - get_user_timezone_offset()) * HOURSECS;
     $endtime += $this->endtimeminute * MINSECS;
     return $endtime;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:9,代码来源:pmclass.class.php


示例3: set_parameters

 /**
  * Sets the parameters property of the extended class
  *
  * Sets the parameters property of the extended file resource class
  *
  * @param    USER  global object
  * @param    CFG   global object
  */
 function set_parameters()
 {
     global $USER, $CFG;
     $site = get_site();
     $this->parameters = array('label2' => array('langstr' => "", 'value' => '/optgroup'), 'label3' => array('langstr' => get_string('course'), 'value' => 'optgroup'), 'courseid' => array('langstr' => 'id', 'value' => $this->course->id), 'coursefullname' => array('langstr' => get_string('fullname'), 'value' => $this->course->fullname), 'courseshortname' => array('langstr' => get_string('shortname'), 'value' => $this->course->shortname), 'courseidnumber' => array('langstr' => get_string('idnumbercourse'), 'value' => $this->course->idnumber), 'coursesummary' => array('langstr' => get_string('summary'), 'value' => $this->course->summary), 'courseformat' => array('langstr' => get_string('format'), 'value' => $this->course->format), 'courseteacher' => array('langstr' => get_string('wordforteacher'), 'value' => $this->course->teacher), 'courseteachers' => array('langstr' => get_string('wordforteachers'), 'value' => $this->course->teachers), 'coursestudent' => array('langstr' => get_string('wordforstudent'), 'value' => $this->course->student), 'coursestudents' => array('langstr' => get_string('wordforstudents'), 'value' => $this->course->students), 'label4' => array('langstr' => "", 'value' => '/optgroup'), 'label5' => array('langstr' => get_string('miscellaneous'), 'value' => 'optgroup'), 'lang' => array('langstr' => get_string('preferredlanguage'), 'value' => current_language()), 'sitename' => array('langstr' => get_string('fullsitename'), 'value' => format_string($site->fullname)), 'serverurl' => array('langstr' => get_string('serverurl', 'resource', $CFG), 'value' => $CFG->wwwroot), 'currenttime' => array('langstr' => get_string('time'), 'value' => time()), 'encryptedcode' => array('langstr' => get_string('encryptedcode'), 'value' => $this->set_encrypted_parameter()), 'label6' => array('langstr' => "", 'value' => '/optgroup'));
     if (!empty($USER->id)) {
         $userparameters = array('label1' => array('langstr' => get_string('user'), 'value' => 'optgroup'), 'userid' => array('langstr' => 'id', 'value' => $USER->id), 'userusername' => array('langstr' => get_string('username'), 'value' => $USER->username), 'useridnumber' => array('langstr' => get_string('idnumber'), 'value' => $USER->idnumber), 'userfirstname' => array('langstr' => get_string('firstname'), 'value' => $USER->firstname), 'userlastname' => array('langstr' => get_string('lastname'), 'value' => $USER->lastname), 'userfullname' => array('langstr' => get_string('fullname'), 'value' => fullname($USER)), 'useremail' => array('langstr' => get_string('email'), 'value' => $USER->email), 'usericq' => array('langstr' => get_string('icqnumber'), 'value' => $USER->icq), 'userphone1' => array('langstr' => get_string('phone') . ' 1', 'value' => $USER->phone1), 'userphone2' => array('langstr' => get_string('phone') . ' 2', 'value' => $USER->phone2), 'userinstitution' => array('langstr' => get_string('institution'), 'value' => $USER->institution), 'userdepartment' => array('langstr' => get_string('department'), 'value' => $USER->department), 'useraddress' => array('langstr' => get_string('address'), 'value' => $USER->address), 'usercity' => array('langstr' => get_string('city'), 'value' => $USER->city), 'usertimezone' => array('langstr' => get_string('timezone'), 'value' => get_user_timezone_offset()), 'userurl' => array('langstr' => get_string('webpage'), 'value' => $USER->url));
         $this->parameters = $userparameters + $this->parameters;
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:18,代码来源:resource.class.php


示例4: test_pm_timestamp

 /**
  * Test pm_gmt_from_usertime() function
  * @param array $intimeparts the input time components array
  * @param float|int|string $timezone the timezone of $intimestamp
  * @param int $outtimestamp the GMT timestamp for $intimestamp in $timezone
  * @dataProvider pm_timestamp_dataprovider
  */
 public function test_pm_timestamp($intimeparts, $timezone, $outtimestamp)
 {
     if ($outtimestamp == 0) {
         $outtimestamp = mktime(2, 3, 4, 1, 1, 2013);
     }
     if (get_user_timezone_offset($timezone) == 99) {
         $this->markTestSkipped("\nSkipping test_pm_gmt_from_usertime() with undefined timezone = '{$timezone}'\n");
     } else {
         if (is_array($outtimestamp)) {
             $outtimestamp = call_user_func_array('mktime', $outtimestamp);
         }
         $this->assertEquals($outtimestamp, pm_timestamp($intimeparts['hour'], $intimeparts['minute'], $intimeparts['second'], $intimeparts['month'], $intimeparts['day'], $intimeparts['year'], $timezone));
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:21,代码来源:pm_timestamp_test.php


示例5: date

 public function date($message)
 {
     $offset = get_user_timezone_offset();
     $time = $offset < 13 ? $message->time() + $offset : $message->time();
     $now = $offset < 13 ? time() + $offset : time();
     $daysago = floor($now / 86400) - floor($time / 86400);
     $yearsago = (int) date('Y', $now) - (int) date('Y', $time);
     if ($daysago == 0) {
         $content = userdate($time, get_string('strftimetime'));
     } else {
         if ($yearsago == 0) {
             $content = userdate($time, get_string('strftimedateshort'));
         } else {
             $content = userdate($time, get_string('strftimedate'));
         }
     }
     return html_writer::tag('span', s($content), array('class' => 'mail_date'));
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:18,代码来源:renderer.php


示例6: set_parameters

 /**
  * Sets the parameters property of the extended class
  *
  * @param    USER  global object
  * @param    CFG   global object
  */
 function set_parameters()
 {
     global $USER, $CFG;
     $site = get_site();
     $littlecfg = new object();
     // to avoid some notices later
     $littlecfg->wwwroot = $CFG->wwwroot;
     $courseparameters = array('label3' => array('langstr' => get_string('course'), 'value' => 'optgroup'), 'courseid' => array('langstr' => 'id', 'value' => $this->course->id), 'coursefullname' => array('langstr' => get_string('fullnamecourse'), 'value' => $this->course->fullname), 'courseshortname' => array('langstr' => get_string('shortnamecourse'), 'value' => $this->course->shortname), 'courseidnumber' => array('langstr' => get_string('idnumbercourse'), 'value' => $this->course->idnumber), 'coursesummary' => array('langstr' => get_string('summary'), 'value' => $this->course->summary), 'courseformat' => array('langstr' => get_string('format'), 'value' => $this->course->format));
     $roles = get_all_roles();
     $coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id);
     $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS);
     foreach ($roles as $role) {
         $courseparameters['course' . $role->shortname] = array('langstr' => get_string('yourwordforx', '', $role->name), 'value' => $role->localname);
     }
     $courseparameters['label4'] = array('langstr' => '', 'value' => '/optgroup');
     $miscparameters = array('label5' => array('langstr' => get_string('miscellaneous'), 'value' => 'optgroup'), 'lang' => array('langstr' => get_string('preferredlanguage'), 'value' => current_language()), 'sitename' => array('langstr' => get_string('fullsitename'), 'value' => format_string($site->fullname)), 'serverurl' => array('langstr' => get_string('serverurl', 'resource', $littlecfg), 'value' => $littlecfg->wwwroot), 'currenttime' => array('langstr' => get_string('time'), 'value' => time()), 'encryptedcode' => array('langstr' => get_string('encryptedcode'), 'value' => $this->set_encrypted_parameter()), 'label6' => array('langstr' => "", 'value' => '/optgroup'));
     $userparameters = array();
     if (!empty($USER->id)) {
         $userparameters = array('label1' => array('langstr' => get_string('user'), 'value' => 'optgroup'), 'userid' => array('langstr' => 'id', 'value' => $USER->id), 'userusername' => array('langstr' => get_string('username'), 'value' => $USER->username), 'useridnumber' => array('langstr' => get_string('idnumber'), 'value' => $USER->idnumber), 'userfirstname' => array('langstr' => get_string('firstname'), 'value' => $USER->firstname), 'userlastname' => array('langstr' => get_string('lastname'), 'value' => $USER->lastname), 'userfullname' => array('langstr' => get_string('fullnameuser'), 'value' => fullname($USER)), 'useremail' => array('langstr' => get_string('email'), 'value' => $USER->email), 'usericq' => array('langstr' => get_string('icqnumber'), 'value' => $USER->icq), 'userphone1' => array('langstr' => get_string('phone') . ' 1', 'value' => $USER->phone1), 'userphone2' => array('langstr' => get_string('phone2') . ' 2', 'value' => $USER->phone2), 'userinstitution' => array('langstr' => get_string('institution'), 'value' => $USER->institution), 'userdepartment' => array('langstr' => get_string('department'), 'value' => $USER->department), 'useraddress' => array('langstr' => get_string('address'), 'value' => $USER->address), 'usercity' => array('langstr' => get_string('city'), 'value' => $USER->city), 'usertimezone' => array('langstr' => get_string('timezone'), 'value' => get_user_timezone_offset()), 'userurl' => array('langstr' => get_string('webpage'), 'value' => $USER->url), 'label2' => array('langstr' => "", 'value' => '/optgroup'));
     }
     $this->parameters = array_merge($userparameters, $courseparameters, $miscparameters);
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:28,代码来源:resource.class.php


示例7: intval

}
if (!isset($frm->an_emailexpiredteacher)) {
    $frm->an_emailexpiredteacher = '';
}
if (!isset($frm->an_sorttype)) {
    $frm->an_sorttype = 'ttl';
}
if (isset($CFG->an_cutoff)) {
    $cutoff = intval($CFG->an_cutoff);
    $mins = $cutoff % 60;
    $hrs = ($cutoff - $mins) / 60;
    $frm->an_cutoff_hour = $hrs;
    $frm->an_cutoff_min = $mins;
}
if (!isset($frm->an_cutoff_hour)) {
    $timezone = format_float(get_user_timezone_offset(), 1);
    $frm->an_cutoff_hour = intval($timezone);
    $frm->an_cutoff_min = intval(round($timezone)) != intval($timezone) ? 35 : 5;
}
if (!isset($frm->acceptmethods)) {
    $frm->acceptmethods = get_list_of_payment_methods();
    $CFG->an_acceptmethods = implode(',', $frm->acceptmethods);
}
if (!isset($frm->acceptccs)) {
    $frm->acceptccs = array_keys(get_list_of_creditcards());
    $CFG->an_acceptccs = implode(',', $frm->acceptccs);
}
if (!isset($frm->acceptechecktypes)) {
    $frm->acceptechecktypes = get_list_of_bank_account_types();
    $CFG->an_acceptechecktypes = implode(',', $frm->acceptechecktypes);
}
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:config_form.php


示例8: test_get_user_timezone_offset

 public function test_get_user_timezone_offset()
 {
     // This is a useless function, the timezone offset may be changing!
     $this->assertSame(-5.0, get_user_timezone_offset('America/New_York'));
     $this->assertDebuggingCalled();
     $this->assertSame(-1.0, get_user_timezone_offset(-1));
     $this->assertSame(1.0, get_user_timezone_offset(1));
     $this->assertSame(1.0, get_user_timezone_offset('Europe/Prague'));
     $this->assertSame(8.0, get_user_timezone_offset('Australia/Perth'));
     $this->assertSame(12.0, get_user_timezone_offset('Pacific/Auckland'));
     $this->resetDebugging();
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:12,代码来源:date_legacy_test.php


示例9: write_date

 /**
  * Write one date somewhere in the worksheet
  * @param integer $row    Zero indexed row
  * @param integer $col    Zero indexed column
  * @param string  $date   The date to write in UNIX timestamp format
  * @param mixed   $format The XF format for the cell
  */
 function write_date($row, $col, $date, $format=null) {
 /// Calculate the internal PEAR format
     $format = $this->MoodleExcelFormat2PearExcelFormat($format);
 /// Convert the date to Excel format
     $timezone = get_user_timezone_offset();
     if ($timezone == 99) {
         // system timezone offset in seconds
         $offset = (int)date('Z');
     } else {
         $offset = (int)($timezone * HOURSECS * 2);
     }
     $value = ((usertime($date) + $offset) / 86400) + 25569;
 /// Add  the date safely to the PEAR Worksheet
     $this->pear_excel_worksheet->writeNumber($row, $col, $value, $format);
 }
开发者ID:nuckey,项目名称:moodle,代码行数:22,代码来源:excellib.class.php


示例10: stats_getdate

function stats_getdate($time, $timezone = 99)
{
    $timezone = get_user_timezone_offset($timezone);
    if (abs($timezone) > 13) {
        // Server time
        return getdate($time);
    }
    // There is no gmgetdate so we use gmdate instead
    $time += intval((double) $timezone * HOURSECS);
    $datestring = strftime('%S_%M_%H_%d_%m_%Y_%w_%j_%A_%B', $time);
    list($getdate['seconds'], $getdate['minutes'], $getdate['hours'], $getdate['mday'], $getdate['mon'], $getdate['year'], $getdate['wday'], $getdate['yday'], $getdate['weekday'], $getdate['month']) = explode('_', $datestring);
    return $getdate;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:13,代码来源:statslib.php


示例11: facetofaceb_date_parse_from_format

/**
 * returns unix timestamp from a date string depending on the date format
 *
 * @param string $format e.g. "d/m/Y" - see date_parse_from_format for supported formats
 * @param string $date a date to be converted e.g. "12/06/12"
 * @return int unix timestamp (0 if fails to parse)
 */
function facetofaceb_date_parse_from_format($format, $date) {

    global $CFG;
    $tz = isset($CFG->timezone) ? $CFG->timezone : 99;
    $timezone = get_user_timezone_offset($tz);
    $dateArray = array();
    $dateArray = date_parse_from_format($format, $date);
    if (is_array($dateArray) && isset($dateArray['error_count']) &&
            $dateArray['error_count'] == 0) {
        if (abs($timezone) > 13) {
            $time = mktime($dateArray['hour'], $dateArray['minute'], $dateArray['second'], $dateArray['month'], $dateArray['day'], $dateArray['year']);
        } else {
            $time = gmmktime($dateArray['hour'], $dateArray['minute'], $dateArray['second'], $dateArray['month'], $dateArray['day'], $dateArray['year']);
            $time = usertime($time, $timezone);
        }
        return $time;
    } else {
        return 0;
    }
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:27,代码来源:lib.php


示例12: mediaelementjs_get_variable_values

/**
 * Get the parameter values that may be appended to URL
 * @param object $url module instance
 * @param object $cm
 * @param object $course
 * @param object $config module config options
 * @return array of parameter values
 */
function mediaelementjs_get_variable_values($url, $cm, $course, $config)
{
    global $USER, $CFG;
    $site = get_site();
    $values = array('courseid' => $course->id, 'coursefullname' => format_string($course->fullname), 'courseshortname' => $course->shortname, 'courseidnumber' => $course->idnumber, 'coursesummary' => $course->summary, 'courseformat' => $course->format, 'lang' => current_language(), 'sitename' => format_string($site->fullname), 'serverurl' => $CFG->wwwroot, 'currenttime' => time(), 'urlinstance' => $url->id, 'urlcmid' => $cm->id, 'urlname' => format_string($url->name), 'urlidnumber' => $cm->idnumber);
    if (isloggedin()) {
        $values['userid'] = $USER->id;
        $values['userusername'] = $USER->username;
        $values['useridnumber'] = $USER->idnumber;
        $values['userfirstname'] = $USER->firstname;
        $values['userlastname'] = $USER->lastname;
        $values['userfullname'] = fullname($USER);
        $values['useremail'] = $USER->email;
        $values['usericq'] = $USER->icq;
        $values['userphone1'] = $USER->phone1;
        $values['userphone2'] = $USER->phone2;
        $values['userinstitution'] = $USER->institution;
        $values['userdepartment'] = $USER->department;
        $values['useraddress'] = $USER->address;
        $values['usercity'] = $USER->city;
        $values['usertimezone'] = get_user_timezone_offset();
        $values['userurl'] = $USER->url;
    }
    // weak imitation of Single-Sign-On, for backwards compatibility only
    // NOTE: login hack is not included in 2.0 any more, new contrib auth plugin
    //       needs to be createed if somebody needs the old functionality!
    if (!empty($config->secretphrase)) {
        $values['encryptedcode'] = url_get_encrypted_parameter($url, $config);
    }
    //hmm, this is pretty fragile and slow, why do we need it here??
    if ($config->rolesinparams) {
        $roles = get_all_roles();
        $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
        $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS);
        foreach ($roles as $role) {
            $values['course' . $role->shortname] = $role->localname;
        }
    }
    return $values;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:48,代码来源:locallib.php


示例13: usergetmidnight

/**
 * Given a time, return the GMT timestamp of the most recent midnight
 * for the current user.
 *
 * @param int $date Timestamp in GMT
 * @param float $timezone ?
 * @return ?
 */
function usergetmidnight($date, $timezone = 99)
{
    $timezone = get_user_timezone_offset($timezone);
    $userdate = usergetdate($date, $timezone);
    // Time of midnight of this user's day, in GMT
    return make_timestamp($userdate['year'], $userdate['mon'], $userdate['mday'], 0, 0, 0, $timezone);
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:15,代码来源:moodlelib.php


示例14: admin_setting_configcheckbox

// show Quizports on MyMoodle page (default=1)
$settings->add(new admin_setting_configcheckbox('hotpot_enablemymoodle', get_string('enablemymoodle', 'mod_hotpot'), get_string('configenablemymoodle', 'mod_hotpot'), 1));
// enable caching of browser content for each quiz (default=1)
$str = get_string('clearcache', 'mod_hotpot');
$url = new moodle_url('/mod/hotpot/tools/clear_cache.php', array('sesskey' => sesskey()));
$link = html_writer::link($url, $str, array('class' => 'small', 'style' => 'white-space: nowrap', 'onclick' => "this.target='_blank'")) . "\n";
$settings->add(new admin_setting_configcheckbox('hotpot_enablecache', get_string('enablecache', 'mod_hotpot'), get_string('configenablecache', 'mod_hotpot') . ' ' . $link, 1));
// restrict cron job to certain hours of the day (default=never)
if (class_exists('core_date') && method_exists('core_date', 'get_user_timezone')) {
    // Moodle >= 2.9
    $timezone = core_date::get_user_timezone(99);
    $datetime = new DateTime('now', new DateTimeZone($timezone));
    $timezone = ($datetime->getOffset() - dst_offset_on(time(), $timezone)) / 3600.0;
} else {
    // Moodle <= 2.8
    $timezone = get_user_timezone_offset();
}
if (abs($timezone) > 13) {
    $timezone = 0;
} else {
    if ($timezone > 0) {
        $timezone = $timezone - 24;
    }
}
$options = array();
for ($i = 0; $i <= 23; $i++) {
    $options[($i - $timezone) % 24] = gmdate('H:i', $i * HOURSECS);
}
$settings->add(new admin_setting_configmultiselect('hotpot_enablecron', get_string('enablecron', 'mod_hotpot'), get_string('configenablecron', 'mod_hotpot'), array(), $options));
// enable embedding of swf media objects inhotpot quizzes (default=1)
$settings->add(new admin_setting_configcheckbox('hotpot_enableswf', get_string('enableswf', 'mod_hotpot'), get_string('configenableswf', 'mod_hotpot'), 1));
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:31,代码来源:settings.php


示例15: get_end_time

 function get_end_time()
 {
     $endtime = ($this->endtimehour - get_user_timezone_offset()) * HOURSECS;
     $endtime += $this->endtimeminute * MINSECS;
     return $endtime;
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:6,代码来源:cmclass.class.php


示例16: intval

}
if (!isset($frm->an_emailexpiredteacher)) {
    $frm->an_emailexpiredteacher = '';
}
if (!isset($frm->an_sorttype)) {
    $frm->an_sorttype = 'ttl';
}
if (isset($CFG->an_cutoff)) {
    $cutoff = intval($CFG->an_cutoff);
    $mins = $cutoff % 60;
    $hrs = ($cutoff - $mins) / 60;
    $frm->an_cutoff_hour = $hrs;
    $frm->an_cutoff_min = $mins;
}
if (!isset($frm->an_cutoff_hour)) {
    $timezone = round(get_user_timezone_offset(), 1);
    $frm->an_cutoff_hour = intval($timezone);
    $frm->an_cutoff_min = intval(round($timezone)) != intval($timezone) ? 35 : 5;
}
if (!isset($frm->acceptmethods)) {
    $frm->acceptmethods = get_list_of_payment_methods();
    $CFG->an_acceptmethods = implode(',', $frm->acceptmethods);
}
if (!isset($frm->acceptccs)) {
    $frm->acceptccs = array_keys(get_list_of_creditcards());
    $CFG->an_acceptccs = implode(',', $frm->acceptccs);
}
if (!isset($frm->acceptechecktypes)) {
    $frm->acceptechecktypes = get_list_of_bank_account_types();
    $CFG->an_acceptechecktypes = implode(',', $frm->acceptechecktypes);
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:config_form.php


示例17: write_date

 /**
  * Write one date somewhere in the worksheet
  * @param integer $row    Zero indexed row
  * @param integer $col    Zero indexed column
  * @param string  $date   The date to write in UNIX timestamp format
  * @param mixed   $format The XF format for the cell
  */
 function write_date($row, $col, $date, $format = null)
 {
     /// Calculate the internal PEAR format
     $format = $this->MoodleExcelFormat2PearExcelFormat($format);
     /// Convert the date to Excel format
     $timezone = get_user_timezone_offset();
     $value = (usertime($date) + (int) ($timezone * HOURSECS * 2)) / 86400 + 25569;
     /// Add  the date safely to the PEAR Worksheet
     $this->pear_excel_worksheet->writeNumber($row, $col, $value, $format);
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:17,代码来源:excellib.class.php


示例18: calendar_show_month_detailed

function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $courseid)
{
    global $CFG, $SESSION, $USER, $CALENDARDAYS;
    global $day, $mon, $yr;
    $getvars = 'from=month&amp;cal_d=' . $day . '&amp;cal_m=' . $mon . '&amp;cal_y=' . $yr;
    // For filtering
    $display =& new stdClass();
    $display->minwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY);
    $display->maxwday = $display->minwday + 6;
    if (!empty($m) && !empty($y)) {
        $thisdate = usergetdate(time());
        // Time and day at the user's location
        if ($m == $thisdate['mon'] && $y == $thisdate['year']) {
            // Navigated to this month
            $date = $thisdate;
            $display->thismonth = true;
        } else {
            // Navigated to other month, let's do a nice trick and save us a lot of work...
            if (!checkdate($m, 1, $y)) {
                $date = array('mday' => 1, 'mon' => $thisdate['mon'], 'year' => $thisdate['year']);
                $display->thismonth = true;
            } else {
                $date = array('mday' => 1, 'mon' => $m, 'year' => $y);
                $display->thismonth = false;
            }
        }
    } else {
        $date = usergetdate(time());
        $display->thismonth = true;
    }
    // Fill in the variables we 're going to use, nice and tidy
    list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']);
    // This is what we want to display
    $display->maxdays = calendar_days_in_month($m, $y);
    $startwday = 0;
    if (get_user_timezone_offset() < 99) {
        // We 'll keep these values as GMT here, and offset them when the time comes to query the db
        $display->tstart = gmmktime(0, 0, 0, $m, 1, $y);
        // This is GMT
        $display->tend = gmmktime(23, 59, 59, $m, $display->maxdays, $y);
        // GMT
        $startwday = gmdate('w', $display->tstart);
        // $display->tstart is already GMT, so don't use date(): messes with server's TZ
    } else {
        // no timezone info specified
        $display->tstart = mktime(0, 0, 0, $m, 1, $y);
        $display->tend = mktime(23, 59, 59, $m, $display->maxdays, $y);
        $startwday = date('w', $display->tstart);
        // $display->tstart not necessarily GMT, so use date()
    }
    // Align the starting weekday to fall in our display range
    if ($startwday < $display->minwday) {
        $startwday += 7;
    }
    // Get events from database
    $events = calendar_get_events(usertime($display->tstart), usertime($display->tend), $users, $groups, $courses);
    if (!empty($events)) {
        foreach ($events as $eventid => $event) {
            if (!empty($event->modulename)) {
                $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
                if (!groups_course_module_visible($cm)) {
                    unset($events[$eventid]);
                }
            }
        }
    }
    // Extract information: events vs. time
    calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
    $text = '';
    if (!isguest() && !empty($USER->id) && calendar_user_can_add_event()) {
        $text .= '<div class="buttons"><form action="' . CALENDAR_URL . 'event.php" method="get">';
        $text .= '<div>';
        $text .= '<input type="hidden" name="action" value="new" />';
        $text .= '<input type="hidden" name="course" value="' . $courseid . '" />';
        $text .= '<input type="hidden" name="cal_m" value="' . $m . '" />';
        $text .= '<input type="hidden" name="cal_y" value="' . $y . '" />';
        $text .= '<input type="submit" value="' . get_string('newevent', 'calendar') . '" />';
        $text .= '</div></form></div>';
    }
    $text .= '<label for="cal_course_flt_jump">' . get_string('detailedmonthview', 'calendar') . ':</label>' . calendar_course_filter_selector($getvars);
    echo '<div class="header">' . $text . '</div>';
    echo '<div class="controls">';
    echo calendar_top_controls('month', array('id' => $courseid, 'm' => $m, 'y' => $y));
    echo '</div>';
    // Start calendar display
    echo '<table class="calendarmonth"><tr class="weekdays">';
    // Begin table. First row: day names
    // Print out the names of the weekdays
    for ($i = $display->minwday; $i <= $display->maxwday; ++$i) {
        // This uses the % operator to get the correct weekday no matter what shift we have
        // applied to the $display->minwday : $display->maxwday range from the default 0 : 6
        echo '<th scope="col">' . get_string($CALENDARDAYS[$i % 7], 'calendar') . '</th>';
    }
    echo '</tr><tr>';
    // End of day names; prepare for day numbers
    // For the table display. $week is the row; $dayweek is the column.
    $week = 1;
    $dayweek = $startwday;
    // Paddding (the first week may have blank days in the beginning)
    for ($i = $display->minwday; $i < $startwday; ++$i) {
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:view.php


示例19: timestamp_to_date_string

 /**
  * Returns a formatted string that represents a date in user time.
  *
  * Returns a formatted string that represents a date in user time
  * <b>WARNING: note that the format is for strftime(), not date().</b>
  * Because of a bug in most Windows time libraries, we can't use
  * the nicer %e, so we have to use %d which has leading zeroes.
  * A lot of the fuss in the function is just getting rid of these leading
  * zeroes as efficiently as possible.
  *
  * If parameter fixday = true (default), then take off leading
  * zero from %d, else maintain it.
  *
  * @param int $time the timestamp in UTC, as obtained from the database
  * @param string $format strftime format
  * @param int|float|string $timezone the timezone to use
  *        {@link http://docs.moodle.org/dev/Time_API#Timezone}
  * @param bool $fixday if true then the leading zero from %d is removed,
  *        if false then the leading zero is maintained
  * @param bool $fixhour if true then the leading zero from %I is removed,
  *        if false then the leading zero is maintained
  * @return string the formatted date/time
  */
 public function timestamp_to_date_string($time, $format, $timezone, $fixday, $fixhour)
 {
     global $CFG;
     if (empty($format)) {
         $format = get_string('strftimedaydatetime', 'langconfig');
     }
     if (!empty($CFG->nofixday)) {
         // Config.php can force %d not to be fixed.
         $fixday = false;
     } else {
         if ($fixday) {
             $formatnoday = str_replace('%d', 'DD', $format);
             $fixday = $formatnoday != $format;
             $format = $formatnoday;
         }
     }
     // Note: This logic about fixing 12-hour time to remove unnecessary leading
     // zero is required because on Windows, PHP strftime function does not
     // support the correct 'hour without leading zero' parameter (%l).
     if (!empty($CFG->nofixhour)) {
         // Config.php can force %I not to be fixed.
         $fixhour = false;
     } else {
         if ($fixhour) {
             $formatnohour = str_replace('%I', 'HH', $format);
             $fixhour = $formatnohour != $format;
             $format = $formatnohour;
         }
     }
     // Add daylight saving offset for string timezones only, as we can't get dst for
     // float values. if timezone is 99 (user default timezone), then try update dst.
     if (99 == $timezone || !is_numeric($timezone)) {
         $time += dst_offset_on($time, $timezone);
     }
     $timezone = get_user_timezone_offset($timezone);
     // If we are running under Windows convert to windows encoding and then back to UTF-8
     // (because it's impossible to specify UTF-8 to fetch locale info in Win32).
     if (abs($timezone) > 13) {
         // Server time.
         $datestring = date_format_string($time, $format, $timezone);
         if ($fixday) {
             $daystring = ltrim(str_replace(array(' 0', ' '), '', strftime(' %d', $time)));
             $datestring = str_replace('DD', $daystring, $datestring);
         }
         if ($fixhour) {
             $hourstring = ltrim(str_replace(array(' 0', ' '), '', strftime(' %I', $time)));
             $datestring = str_replace('HH', $hourstring, $datestring);
         }
     } else {
         $time += (int) ($timezone * 3600);
         $datestring = date_format_string($time, $format, $timezone);
         if ($fixday) {
             $daystring = ltrim(str_replace(array(' 0', ' '), '', gmstrftime(' %d', $time)));
             $datestring = str_replace('DD', $daystring, $datestring);
         }
         if ($fixhour) {
             $hourstring = ltrim(str_replace(array(' 0', ' '), '', gmstrftime(' %I', $time)));
             $datestring = str_replace('HH', $hourstring, $datestring);
         }
     }
     return $datestring;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:85,代码来源:structure.php


示例20: usertime

/**
 * Given a GMT timestamp (seconds since epoch), offsets it by
 * the timezone.  eg 3pm in India is 3pm GMT - 7 * 3600 seconds
 *
 * @package core
 * @category time
 * @uses HOURSECS
 * @param int $date Timestamp in GMT
 * @param float|int|string $timezone timezone to calculate GMT time offset before
 *        calculating user time, 99 is default user timezone
 *        {@link http://docs.moodle.org/dev/Time_API#Timezone}
 * @return int
 */
function usertime($date, $timezone=99) {

    $timezone = get_user_timezone_offset($timezone);

    if (abs($timezone) > 13) {
        return $date;
    }
    return $date - (int)($timezone * HOURSECS);
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:22,代码来源:moodlelib.php



注:本文中的get_user_timezone_offset函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_user_to_edit函数代码示例发布时间:2022-05-15
下一篇:
PHP get_user_timezone函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap