本文整理汇总了PHP中CTimeZone::enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP CTimeZone::enabled方法的具体用法?PHP CTimeZone::enabled怎么用?PHP CTimeZone::enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeZone
的用法示例。
在下文中一共展示了CTimeZone::enabled方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tasksFormatDate
function tasksFormatDate($in_date)
{
$date = $in_date;
$strDate = false;
if (!is_int($in_date)) {
$date = MakeTimeStamp($in_date);
}
if ($date === false || $date === -1 || $date === 0) {
$date = MakeTimeStamp($in_date);
}
// It can be other date on server (relative to client), ...
$bTzWasDisabled = !CTimeZone::enabled();
if ($bTzWasDisabled) {
CTimeZone::enable();
}
$ts = time() + CTimeZone::getOffset();
// ... so shift cur timestamp to compensate it.
if ($bTzWasDisabled) {
CTimeZone::disable();
}
$curDateStrAtClient = date('d.m.Y', $ts);
$yesterdayDateStrAtClient = date('d.m.Y', strtotime('-1 day', $ts));
if ($curDateStrAtClient === date('d.m.Y', $date)) {
$strDate = FormatDate("today", $date);
} elseif ($yesterdayDateStrAtClient === date('d.m.Y', $date)) {
$strDate = FormatDate("yesterday", $date);
} else {
if (defined('FORMAT_DATE')) {
$strDate = FormatDate(CDatabase::DateFormatToPHP(FORMAT_DATE), $date);
} else {
$strDate = FormatDate("d.m.Y", $date);
}
}
return $strDate;
}
示例2: getList
public static function getList($userId, $taskId, array $parameters = array())
{
$data = array();
$task = static::getTask($userId, $taskId);
if ($task !== null && $task->checkCanRead()) {
$res = \CTaskLog::GetList(array('CREATED_DATE' => 'DESC'), array('TASK_ID' => $taskId));
$tzDisabled = !\CTimeZone::enabled();
if ($tzDisabled) {
\CTimeZone::enable();
}
$tzOffset = \CTimeZone::getOffset();
if ($tzDisabled) {
\CTimeZone::disable();
}
while (true) {
if ($parameters['ESCAPE_DATA']) {
$item = $res->GetNext();
} else {
$item = $res->fetch();
}
if (!$item) {
break;
}
// Adjust unix timestamps to "bitrix timestamps"
if (isset(\CTaskLog::$arComparedFields[$item['FIELD']]) && \CTaskLog::$arComparedFields[$item['FIELD']] === 'date') {
$item['TO_VALUE'] = $item['TO_VALUE'] + $tzOffset;
$item['FROM_VALUE'] = $item['FROM_VALUE'] + $tzOffset;
}
$data[] = $item;
}
}
return array('DATA' => $data, 'CAN' => array());
}
示例3: convertDateStringToTimestamp
private static function convertDateStringToTimestamp($operation, $value)
{
switch ($operation) {
case self::OP_DATE_TODAY:
case self::OP_DATE_YESTERDAY:
case self::OP_DATE_TOMORROW:
case self::OP_DATE_CUR_WEEK:
case self::OP_DATE_PREV_WEEK:
case self::OP_DATE_NEXT_WEEK:
case self::OP_DATE_CUR_MONTH:
case self::OP_DATE_PREV_MONTH:
case self::OP_DATE_NEXT_MONTH:
$value = '';
break;
case self::OP_DATE_LAST_DAYS:
case self::OP_DATE_NEXT_DAYS:
$value = (int) $value;
break;
default:
case self::OP_EQUAL:
case self::OP_NOT_EQUAL:
case self::OP_STRICTLY_LESS:
case self::OP_STRICTLY_GREATER:
case self::OP_LESS_OR_EQUAL:
case self::OP_GREATER_OR_EQUAL:
$bTzWasDisabled = !CTimeZone::enabled();
if ($bTzWasDisabled) {
CTimeZone::enable();
}
// get correct UnixTimestamp
$value = (int) MakeTimeStamp($value) - CTimeZone::getOffset();
if ($bTzWasDisabled) {
CTimeZone::disable();
}
break;
}
return $value;
}
示例4: CLearnPath
$arGroupsPeriods = CLearnAccessMacroses::getActiveLearningGroupsPeriod($courseLessonId, $USER->getId());
if ($arGroupsPeriods['IS_EXISTS']) {
$arResult['LEARNING_GROUP_ACTIVE_FROM'] = $arGroupsPeriods['ACTIVE_FROM'];
$arResult['LEARNING_GROUP_ACTIVE_TO'] = $arGroupsPeriods['ACTIVE_TO'];
$activeFromMap = CLearnAccessMacroses::getActiveLearningChaptersPeriod($courseLessonId, $USER->getId());
if ($activeFromMap !== false) {
$arResult['LEARNING_GROUP_CHAPTERS_ACTIVE_FROM'] = $activeFromMap;
}
$oPath = new CLearnPath();
$oPath->ImportUrlencoded($arParams['LESSON_PATH']);
$arPath = $oPath->GetPathAsArray();
if (count($arPath) >= 2) {
$secondLevelLesson = $arPath[1];
if (isset($arResult['LEARNING_GROUP_CHAPTERS_ACTIVE_FROM'][$secondLevelLesson])) {
$activeFrom = $arResult['LEARNING_GROUP_CHAPTERS_ACTIVE_FROM'][$secondLevelLesson];
$bTzWasDisabled = !CTimeZone::enabled();
if ($bTzWasDisabled) {
CTimeZone::enable();
}
$tzOffset = CTimeZone::getOffset();
if ($bTzWasDisabled) {
CTimeZone::disable();
}
// Adjust unix timestamp to bitrix-timestamp for correct comparision below
$nowTimestamp = time() + $tzOffset;
if ($nowTimestamp < MakeTimeStamp($activeFrom)) {
$delayed = $activeFrom;
}
}
}
}
示例5: getDatetimeExpressionTemplate
/**
* Return datetime template for old api emulation.
*
* @return string
*/
public static function getDatetimeExpressionTemplate()
{
if (self::$datetimeTemplate === null) {
$helper = Application::getConnection()->getSqlHelper();
$format = Context::getCurrent()->getCulture()->getDateTimeFormat();
$datetimeFieldName = '#FIELD#';
$datetimeField = $datetimeFieldName;
if (\CTimeZone::enabled()) {
$diff = \CTimeZone::getOffset();
if ($diff != 0) {
$datetimeField = $helper->addSecondsToDateTime($diff, $datetimeField);
}
unset($diff);
}
self::$datetimeTemplate = str_replace(array('%', $datetimeFieldName), array('%%', '%1$s'), $helper->formatDate($format, $datetimeField));
unset($datetimeField, $datetimeFieldName, $format, $helper);
}
return self::$datetimeTemplate;
}
示例6: UnifyFields
public static function UnifyFields(&$value, $key)
{
if (array_key_exists($key, self::$arComparedFields)) {
switch (self::$arComparedFields[$key]) {
case "integer":
$value = intval($value);
break;
case "string":
$value = trim($value);
break;
case "array":
if (!is_array($value)) {
$value = explode(",", $value);
}
$value = array_unique(array_filter(array_map("trim", $value)));
sort($value);
break;
case "date":
$value = MakeTimeStamp($value);
if (!$value) {
$value = strtotime($value);
// There is correct Unix timestamp in return value
// CTimeZone::getOffset() substraction here???
} else {
// It can be other date on server (relative to client), ...
$bTzWasDisabled = !CTimeZone::enabled();
if ($bTzWasDisabled) {
CTimeZone::enable();
}
$value -= CTimeZone::getOffset();
// get correct UnixTimestamp
if ($bTzWasDisabled) {
CTimeZone::disable();
}
// We mustn't store result of MakeTimestamp() in DB,
// because it is shifted for time zone offset already,
// which can't be restored.
}
break;
case "bool":
if ($value != "Y") {
$value = "N";
}
break;
}
}
}
示例7: getSqlForTimestamps
private static function getSqlForTimestamps($key, $val, $userID, $sAliasPrefix, $bGetZombie)
{
static $ts = null;
// some fixed timestamp of "now" (for consistency)
if ($ts === null) {
$ts = CTasksPerHitOption::getHitTimestamp();
}
$bTzWasDisabled = !CTimeZone::enabled();
if ($bTzWasDisabled) {
CTimeZone::enable();
}
// Adjust UNIX TS to "Bitrix timestamp"
$tzOffset = CTimeZone::getOffset();
$val += $tzOffset;
$ts += $tzOffset;
if ($bTzWasDisabled) {
CTimeZone::disable();
}
$arSqlSearch = array();
$arFilter = array('::LOGIC' => 'AND');
$key = ltrim($key);
$res = CTasks::MkOperationFilter($key);
$fieldName = substr($res["FIELD"], 5, -3);
// Cutoff prefix "META:" and suffix "_TS"
$cOperationType = $res["OPERATION"];
$operationSymbol = substr($key, 0, -1 * strlen($res["FIELD"]));
if (substr($cOperationType, 0, 1) !== '#') {
switch ($operationSymbol) {
case '<':
$operationCode = CTaskFilterCtrl::OP_STRICTLY_LESS;
break;
case '>':
$operationCode = CTaskFilterCtrl::OP_STRICTLY_GREATER;
break;
case '<=':
$operationCode = CTaskFilterCtrl::OP_LESS_OR_EQUAL;
break;
case '>=':
$operationCode = CTaskFilterCtrl::OP_GREATER_OR_EQUAL;
break;
case '!=':
$operationCode = CTaskFilterCtrl::OP_NOT_EQUAL;
break;
case '':
case '=':
$operationCode = CTaskFilterCtrl::OP_EQUAL;
break;
default:
CTaskAssert::log('Unknown operation code: ' . $operationSymbol . '; $key = ' . $key . '; it will be silently ignored, incorrect results expected', CTaskAssert::ELL_ERROR);
return $arSqlSearch;
break;
}
} else {
$operationCode = (int) substr($cOperationType, 1);
}
$date1 = $date2 = $cOperationType1 = $cOperationType2 = null;
// Convert cOperationType to format accepted by self::FilterCreate
switch ($operationCode) {
case CTaskFilterCtrl::OP_EQUAL:
case CTaskFilterCtrl::OP_DATE_TODAY:
case CTaskFilterCtrl::OP_DATE_YESTERDAY:
case CTaskFilterCtrl::OP_DATE_TOMORROW:
case CTaskFilterCtrl::OP_DATE_CUR_WEEK:
case CTaskFilterCtrl::OP_DATE_PREV_WEEK:
case CTaskFilterCtrl::OP_DATE_NEXT_WEEK:
case CTaskFilterCtrl::OP_DATE_CUR_MONTH:
case CTaskFilterCtrl::OP_DATE_PREV_MONTH:
case CTaskFilterCtrl::OP_DATE_NEXT_MONTH:
case CTaskFilterCtrl::OP_DATE_NEXT_DAYS:
case CTaskFilterCtrl::OP_DATE_LAST_DAYS:
$cOperationType1 = '>=';
$cOperationType2 = '<=';
break;
case CTaskFilterCtrl::OP_LESS_OR_EQUAL:
$cOperationType1 = '<=';
break;
case CTaskFilterCtrl::OP_GREATER_OR_EQUAL:
$cOperationType1 = '>=';
break;
case CTaskFilterCtrl::OP_NOT_EQUAL:
$cOperationType1 = '<';
$cOperationType2 = '>';
break;
case CTaskFilterCtrl::OP_STRICTLY_LESS:
$cOperationType1 = '<';
break;
case CTaskFilterCtrl::OP_STRICTLY_GREATER:
$cOperationType1 = '>';
break;
default:
CTaskAssert::log('Unknown operation code: ' . $operationCode . '; $key = ' . $key . '; it will be silently ignored, incorrect results expected', CTaskAssert::ELL_ERROR);
return $arSqlSearch;
break;
}
// Convert/generate dates
$ts1 = $ts2 = null;
switch ($operationCode) {
case CTaskFilterCtrl::OP_DATE_TODAY:
$ts1 = $ts2 = $ts;
break;
//.........这里部分代码省略.........
示例8: getTimeZoneOffset
/**
* Not part of public API, for internal use only.
* @deprecated
* @access private
*/
public static function getTimeZoneOffset($userId = false)
{
$bTzWasDisabled = !CTimeZone::enabled();
if ($bTzWasDisabled) {
CTimeZone::enable();
}
if ($userId === false) {
$tzOffset = CTimeZone::getOffset();
} else {
$tzOffset = CTimeZone::getOffset($userId);
}
if ($bTzWasDisabled) {
CTimeZone::disable();
}
return $tzOffset;
}