本文整理汇总了PHP中TimeDate::userTimezone方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeDate::userTimezone方法的具体用法?PHP TimeDate::userTimezone怎么用?PHP TimeDate::userTimezone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeDate
的用法示例。
在下文中一共展示了TimeDate::userTimezone方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testparseDateRange
/**
* @dataProvider dateRanges
*/
public function testparseDateRange($range, $start, $end)
{
$this->time_date->setNow(SugarDateTime::createFromFormat(TimeDate::DB_DATETIME_FORMAT, "2011-08-30 12:01:02", new DateTimeZone($this->time_date->userTimezone())));
$this->time_date->allow_cache = true;
$daterage = $this->time_date->parseDateRange($range);
$this->assertEquals($start, $daterage[0]->format(TimeDate::DB_DATETIME_FORMAT), 'Start date is wrong');
$this->assertEquals($end, $daterage[1]->format(TimeDate::DB_DATETIME_FORMAT), 'End date is wrong');
}
示例2: createGroupUser
/**
* Creates a new Group User
* @param string $name Name of Group User
* @return string GUID of new Group User
*/
function createGroupUser($name)
{
$group = new User();
$group->user_name = $name;
$group->last_name = $name;
$group->is_group = 1;
$group->deleted = 0;
$group->status = 'Active';
// cn: bug 6711
$group->setPreference('timezone', TimeDate::userTimezone());
$group->save();
return $group->id;
}
示例3: getUserDateTimePreferences
/**
* Loads users timedate preferences
*
* @return array 'date' - date format for user ; 'time' - time format for user
*/
public function getUserDateTimePreferences()
{
global $sugar_config, $db, $timedate, $current_user;
$user = $this->_userFocus;
$prefDate = array();
if (!empty($user) && $this->loadPreferences('global')) {
// forced to set this to a variable to compare b/c empty() wasn't working
$timeZone = TimeDate::userTimezone($user);
$timeFormat = $user->getPreference("timef");
$dateFormat = $user->getPreference("datef");
// cn: bug xxxx cron.php fails because of missing preference when admin hasn't logged in yet
$timeZone = empty($timeZone) ? 'America/Los_Angeles' : $timeZone;
if (empty($timeFormat)) {
$timeFormat = $sugar_config['default_time_format'];
}
if (empty($dateFormat)) {
$dateFormat = $sugar_config['default_date_format'];
}
$prefDate['date'] = $dateFormat;
$prefDate['time'] = $timeFormat;
$prefDate['userGmt'] = TimeDate::tzName($timeZone);
$prefDate['userGmtOffset'] = $timedate->getUserUTCOffset($user);
return $prefDate;
} else {
$prefDate['date'] = $timedate->get_date_format();
$prefDate['time'] = $timedate->get_time_format();
if (!empty($user) && $user->object_name == 'User') {
$timeZone = TimeDate::userTimezone($user);
// cn: bug 9171 - if user has no time zone, cron.php fails for InboundEmail
if (!empty($timeZone)) {
$prefDate['userGmt'] = TimeDate::tzName($timeZone);
$prefDate['userGmtOffset'] = $timedate->getUserUTCOffset($user);
}
} else {
$timeZone = TimeDate::userTimezone($current_user);
if (!empty($timeZone)) {
$prefDate['userGmt'] = TimeDate::tzName($timeZone);
$prefDate['userGmtOffset'] = $timedate->getUserUTCOffset($current_user);
}
}
return $prefDate;
}
}
示例4: getUserTimezone
/**
* Gets the time zone for the given user.
*
* @param User $current_user the user
* @return DateTimeZone the user's timezone
*/
protected function getUserTimezone($current_user)
{
$gmtTZ = new DateTimeZone("UTC");
$userTZName = TimeDate::userTimezone($current_user);
if (!empty($userTZName)) {
$tz = new DateTimeZone($userTZName);
} else {
$tz = $gmtTZ;
}
return $tz;
}
示例5: check_weekend
function check_weekend($day)
{
global $current_user;
//get users timezone setting
$timezone = TimeDate::userTimezone($current_user);
$now = new DateTime();
$now->setTimezone(new DateTimeZone($timezone));
$date1 = DateTime::createFromFormat('Y-m-d', $day);
$date = $date1->format('Y-m-d');
$now = $now->format('Y-m-d');
// $GLOBALS['log']->fatal("date2 ".$now);
if ($date1->format('l') == 'Sunday' && $date == $now) {
return 'weekend-today';
} else {
if ($date1->format('l') == 'Saturday' && $date == $now) {
return 'weekend-today';
} else {
if ($date1->format('l') == 'Sunday') {
return 'weekend';
} else {
if ($date1->format('l') == 'Saturday') {
return 'weekend';
} else {
if ($date == $now) {
return 'today';
} else {
return false;
}
}
}
}
}
}
示例6: setDateTimeProperties
private function setDateTimeProperties($field_map = array())
{
global $current_user, $sugar_config;
$timeFormat = $current_user->getUserDateTimePreferences();
$defaultTimeOption = isset($field_map['importlocale_timeformat']) ? $field_map['importlocale_timeformat'] : $timeFormat['time'];
$defaultDateOption = isset($field_map['importlocale_dateformat']) ? $field_map['importlocale_dateformat'] : $timeFormat['date'];
$timeOptions = get_select_options_with_id($sugar_config['time_formats'], $defaultTimeOption);
$dateOptions = get_select_options_with_id($sugar_config['date_formats'], $defaultDateOption);
// get list of valid timezones
$userTZ = isset($field_map['importlocale_timezone']) ? $field_map['importlocale_timezone'] : $current_user->getPreference('timezone');
if (empty($userTZ)) {
$userTZ = TimeDate::userTimezone();
}
$this->ss->assign('TIMEZONE_CURRENT', $userTZ);
$this->ss->assign('TIMEOPTIONS', $timeOptions);
$this->ss->assign('DATEOPTIONS', $dateOptions);
$this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
}
示例7: display
//.........这里部分代码省略.........
// get field type information
$fieldtype = '';
if (isset($properties['type']) && isset($mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])])) {
$fieldtype = ' [' . $mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])] . '] ';
}
if (isset($properties['comment'])) {
$fieldtype .= ' - ' . $properties['comment'];
}
$options[$displayname . $fieldname] = '<option value="' . $fieldname . '" title="' . $displayname . $fieldtype . '"' . $selected . $req_class . '>' . $displayname . $req_mark . '</option>\\n';
}
// get default field value
$defaultFieldHTML = '';
if (!empty($defaultField)) {
$defaultFieldHTML = getControl($_REQUEST['import_module'], $defaultField, $fields[$defaultField], $default_value);
}
// Bug 27046 - Sort the column name picker alphabetically
ksort($options);
$columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'show_remove' => true);
$ret_field_count++;
}
}
$this->ss->assign("COLUMNCOUNT", $ret_field_count);
$this->ss->assign("rows", $columns);
// get list of valid date/time formats
$timeFormat = $current_user->getUserDateTimePreferences();
$timeOptions = get_select_options_with_id($sugar_config['time_formats'], $timeFormat['time']);
$dateOptions = get_select_options_with_id($sugar_config['date_formats'], $timeFormat['date']);
$this->ss->assign('TIMEOPTIONS', $timeOptions);
$this->ss->assign('DATEOPTIONS', $dateOptions);
$this->ss->assign('datetimeformat', $GLOBALS['timedate']->get_cal_date_time_format());
// get list of valid timezones
$userTZ = $current_user->getPreference('timezone');
if (empty($userTZ)) {
$userTZ = TimeDate::userTimezone();
}
$this->ss->assign('TIMEZONE_CURRENT', $userTZ);
$this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
// get currency preference
require_once 'modules/Currencies/ListCurrency.php';
$currency = new ListCurrency();
$cur_id = $locale->getPrecedentPreference('currency', $current_user);
if ($cur_id) {
$selectCurrency = $currency->getSelectOptions($cur_id);
$this->ss->assign("CURRENCY", $selectCurrency);
} else {
$selectCurrency = $currency->getSelectOptions();
$this->ss->assign("CURRENCY", $selectCurrency);
}
$currenciesVars = "";
$i = 0;
foreach ($locale->currencies as $id => $arrVal) {
$currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
$i++;
}
$currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
document.getElementById('symbol').value = currencies[id];
}
eoq;
$this->ss->assign('currencySymbolJs', $currencySymbolsJs);
// fill significant digits dropdown
$significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
$sigDigits = '';
for ($i = 0; $i <= 6; $i++) {