本文整理汇总了PHP中CCalendar::GetDayLen方法的典型用法代码示例。如果您正苦于以下问题:PHP CCalendar::GetDayLen方法的具体用法?PHP CCalendar::GetDayLen怎么用?PHP CCalendar::GetDayLen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCalendar
的用法示例。
在下文中一共展示了CCalendar::GetDayLen方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HandleREvent
private static function HandleREvent(&$res, $item = array(), $Params)
{
// *** $item['~DT_FROM_TS'] & $item['~DT_TO_TS'] - are real FROM AND TO timestamps of the first original event
$item['RRULE'] = $Params['RRULE'];
$item['DT_FROM_TS'] = $Params['DT_FROM_TS'];
$item['DT_TO_TS'] = $Params['DT_TO_TS'];
$item['~DT_FROM_TS'] += date("Z", $item['~DT_FROM_TS']) - date("Z");
$item['~DT_TO_TS'] += date("Z", $item['~DT_TO_TS']) - date("Z");
$offset = CCalendar::GetOffset();
if ($item['DT_SKIP_TIME'] == 'N' && $offset != 0) {
$item['~DT_FROM_TS'] += $offset;
$item['~DT_TO_TS'] += $offset;
$item['~DT_FROM'] = CCalendar::Date($item['~DT_FROM_TS']);
$item['~DT_TO'] = CCalendar::Date($item['~DT_TO_TS']);
}
if ($item['DT_SKIP_TIME'] == 'Y') {
$item['DT_TO_TS'] -= CCalendar::GetDayLen();
}
if ($item['DT_SKIP_TIME'] == 'Y' || $offset == 0) {
$item['DT_FROM'] = CCalendar::Date($item['DT_FROM_TS']);
$item['DT_TO'] = CCalendar::Date($item['DT_TO_TS']);
}
$item['RINDEX'] = $Params['RINDEX'];
self::HandleEvent($res, $item);
}
示例2: FormatICal
private static function FormatICal($Section, $Events)
{
$res = 'BEGIN:VCALENDAR
PRODID:-//Bitrix//Bitrix Calendar//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:' . self::_ICalPaste($Section['NAME']) . '
X-WR-CALDESC:' . self::_ICalPaste($Section['DESCRIPTION']) . "\n";
$localTime = new DateTime();
$localOffset = $localTime->getOffset();
$h24 = CCalendar::GetDayLen();
foreach ($Events as $event) {
//$fts = CCalendar::Timestamp($event['DT_FROM']);
//$tts = CCalendar::Timestamp($event['DT_TO']);
$fts = $event['DT_FROM_TS'];
$tts = $event['DT_TO_TS'];
if ($event['DT_SKIP_TIME'] == 'Y') {
$dtStart = date("Ymd", $event['DT_FROM_TS']);
if ($event['DT_LENGTH'] == $h24) {
$dtEnd = $dtStart;
} else {
$dtEnd = date("Ymd", $event['DT_TO_TS'] - $h24);
}
} else {
$dtStart = date("Ymd\\THis\\Z", $event['DT_FROM_TS'] - $localOffset);
$dtEnd = date("Ymd\\THis\\Z", $event['DT_TO_TS'] - $localOffset);
}
$dtStamp = str_replace('T000000Z', '', date("Ymd\\THisZ", CCalendar::Timestamp($event['TIMESTAMP_X']) - $localOffset));
$uid = md5(uniqid(rand(), true) . $event['ID']) . '@bitrix';
$period = '';
$rrule = CCalendarEvent::ParseRRULE($event['RRULE']);
if ($rrule && isset($rrule['FREQ']) && $rrule['FREQ'] != 'NONE') {
$period = 'RRULE:FREQ=' . $rrule['FREQ'] . ';';
$period .= 'INTERVAL=' . $rrule['INTERVAL'] . ';';
if ($rrule['FREQ'] == 'WEEKLY') {
$period .= 'BYDAY=' . implode(',', $rrule['BYDAY']) . ';';
}
if ($event['DT_SKIP_TIME'] == 'Y') {
if ($event['DT_LENGTH'] == $h24) {
$dtEnd_ = $dtStart;
} else {
$dtEnd_ = date("Ymd", $event['DT_FROM_TS'] + $event['DT_LENGTH'] - $h24 - $localOffset);
}
} else {
$dtEnd_ = date("Ymd\\THisZ", $event['DT_FROM_TS'] + $event['DT_LENGTH'] - $localOffset);
}
if (date("Ymd", $tts) != '20380101') {
$period .= 'UNTIL=' . $dtEnd . ';';
}
$period .= 'WKST=MO';
$dtEnd = $dtEnd_;
$period .= "\n";
}
$res .= 'BEGIN:VEVENT
DTSTART;VALUE=DATE:' . $dtStart . '
DTEND;VALUE=DATE:' . $dtEnd . '
DTSTAMP:' . $dtStamp . '
UID:' . $uid . '
SUMMARY:' . self::_ICalPaste($event['NAME']) . '
DESCRIPTION:' . self::_ICalPaste($event['DESCRIPTION']) . "\n" . $period . '
CLASS:PRIVATE
LOCATION:' . self::_ICalPaste(CCalendar::GetTextLocation($event['LOCATION'])) . '
SEQUENCE:0
STATUS:CONFIRMED
TRANSP:TRANSPARENT
END:VEVENT' . "\n";
}
$res .= 'END:VCALENDAR';
if (!defined('BX_UTF') || BX_UTF !== true) {
$res = $GLOBALS["APPLICATION"]->ConvertCharset($res, LANG_CHARSET, 'UTF-8');
}
return $res;
}
示例3: PreHandleEvent
private static function PreHandleEvent($item)
{
if ($item['IS_MEETING'] && $item['MEETING'] != "" && !is_array($item['MEETING'])) {
$item['MEETING'] = unserialize($item['MEETING']);
if (!is_array($item['MEETING'])) {
$item['MEETING'] = array();
}
}
if (self::CheckRecurcion($item)) {
$tsFrom = CCalendar::Timestamp($item['DATE_FROM']);
$tsTo = CCalendar::Timestamp($item['DATE_TO']);
if ($tsTo - $tsFrom > $item['DT_LENGTH'] + CCalendar::DAY_LENGTH) {
$toTS = $tsFrom + $item['DT_LENGTH'];
if ($item['DT_SKIP_TIME'] == 'Y') {
$toTS -= CCalendar::GetDayLen();
}
$item['DATE_TO'] = CCalendar::Date($toTS);
}
}
if ($item['IS_MEETING']) {
if ($item['ATTENDEES_CODES'] != '') {
$item['ATTENDEES_CODES'] = explode(',', $item['ATTENDEES_CODES']);
}
if ($item['ID'] == $item['PARENT_ID']) {
$item['MEETING_STATUS'] = 'H';
}
}
if (!isset($item['~IS_MEETING'])) {
$item['~IS_MEETING'] = $item['IS_MEETING'];
}
$item['DT_SKIP_TIME'] = $item['DT_SKIP_TIME'] === 'Y' ? 'Y' : 'N';
$item['ACCESSIBILITY'] = trim($item['ACCESSIBILITY']);
$item['IMPORTANCE'] = trim($item['IMPORTANCE']);
if ($item['IMPORTANCE'] == '') {
$item['IMPORTANCE'] = 'normal';
}
$item['PRIVATE_EVENT'] = trim($item['PRIVATE_EVENT']);
$item['~DESCRIPTION'] = self::ParseText($item['DESCRIPTION'], $item['ID'], $item['UF_WEBDAV_CAL_EVENT']);
if (isset($item['UF_CRM_CAL_EVENT']) && is_array($item['UF_CRM_CAL_EVENT']) && count($item['UF_CRM_CAL_EVENT']) == 0) {
$item['UF_CRM_CAL_EVENT'] = '';
}
return $item;
}
示例4: FormatICal
private static function FormatICal($section, $events)
{
global $APPLICATION;
$res = 'BEGIN:VCALENDAR' . "\n" . 'PRODID:-//Bitrix//Bitrix Calendar//EN' . "\n" . 'VERSION:2.0' . "\n" . 'CALSCALE:GREGORIAN' . "\n" . 'METHOD:PUBLISH' . "\n" . 'X-WR-CALNAME:' . self::_ICalPaste($section['NAME']) . "\n" . 'X-WR-CALDESC:' . self::_ICalPaste($section['DESCRIPTION']) . "\n";
$localTime = new DateTime();
$localOffset = $localTime->getOffset();
foreach ($events as $event) {
$fromTs = CCalendar::Timestamp($event['DATE_FROM']);
$toTs = CCalendar::Timestamp($event['DATE_TO']);
if ($event['DT_SKIP_TIME'] === "Y") {
$dtStart = date("Ymd", $fromTs);
$dtEnd = date("Ymd", $toTs + CCalendar::GetDayLen());
} else {
$fromTsUTC = $fromTs - $event['TZ_OFFSET_FROM'];
$toTsUTC = $toTs - $event['TZ_OFFSET_TO'];
$dtStart = date("Ymd\\THis\\Z", $fromTsUTC);
$dtEnd = date("Ymd\\THis\\Z", $toTsUTC);
}
$dtStamp = str_replace('T000000Z', '', date("Ymd\\THisZ", CCalendar::Timestamp($event['TIMESTAMP_X']) - $localOffset));
$uid = md5(uniqid(rand(), true) . $event['ID']) . '@bitrix';
$period = '';
$rrule = CCalendarEvent::ParseRRULE($event['RRULE']);
if ($rrule && isset($rrule['FREQ']) && $rrule['FREQ'] != 'NONE') {
$period = 'RRULE:FREQ=' . $rrule['FREQ'] . ';';
$period .= 'INTERVAL=' . $rrule['INTERVAL'] . ';';
if ($rrule['FREQ'] == 'WEEKLY') {
$period .= 'BYDAY=' . implode(',', $rrule['BYDAY']) . ';';
}
$until = date("Ymd", $event['DATE_TO_TS_UTC']);
if ($until != '20380101') {
$period .= 'UNTIL=' . $until . ';';
}
$period .= 'WKST=MO';
$period .= "\n";
}
$res .= 'BEGIN:VEVENT' . "\n";
if ($event['DT_SKIP_TIME'] === "Y") {
$res .= 'DTSTART;VALUE=DATE:' . $dtStart . "\n" . 'DTEND;VALUE=DATE:' . $dtEnd . "\n";
} else {
$res .= 'DTSTART;VALUE=DATE-TIME:' . $dtStart . "\n" . 'DTEND;VALUE=DATE-TIME:' . $dtEnd . "\n";
}
$res .= 'DTSTAMP:' . $dtStamp . "\n" . 'UID:' . $uid . "\n" . 'SUMMARY:' . self::_ICalPaste($event['NAME']) . "\n" . 'DESCRIPTION:' . self::_ICalPaste($event['DESCRIPTION']) . "\n" . $period . "\n" . 'CLASS:PRIVATE' . "\n" . 'LOCATION:' . self::_ICalPaste(CCalendar::GetTextLocation($event['LOCATION'])) . "\n" . 'SEQUENCE:0' . "\n" . 'STATUS:CONFIRMED' . "\n" . 'TRANSP:TRANSPARENT' . "\n" . 'END:VEVENT' . "\n";
}
$res .= 'END:VCALENDAR';
if (!defined('BX_UTF') || BX_UTF !== true) {
$res = $APPLICATION->ConvertCharset($res, LANG_CHARSET, 'UTF-8');
}
return $res;
}
示例5: ModifyEvent
public static function ModifyEvent($calendarId, $arFields)
{
list($sectionId, $entityType, $entityId) = $calendarId;
$userId = $entityType == 'user' ? $entityId : 0;
self::$silentErrorMode = true;
CCalendar::SetOffset(false, CCalendar::GetOffset($userId));
$entityType = strtolower($entityType);
$eventId = isset($arFields["ID"]) && intval($arFields["ID"]) > 0 ? intval($arFields["ID"]) : 0;
$arNewFields = array("DAV_XML_ID" => $arFields['XML_ID'], "CAL_DAV_LABEL" => isset($arFields['PROPERTY_BXDAVCD_LABEL']) && strlen($arFields['PROPERTY_BXDAVCD_LABEL']) > 0 ? $arFields['PROPERTY_BXDAVCD_LABEL'] : '', "DAV_EXCH_LABEL" => isset($arFields['PROPERTY_BXDAVEX_LABEL']) && strlen($arFields['PROPERTY_BXDAVEX_LABEL']) > 0 ? $arFields['PROPERTY_BXDAVEX_LABEL'] : '', "ID" => $eventId, 'NAME' => $arFields["NAME"] ? $arFields["NAME"] : GetMessage('EC_NONAME_EVENT'), 'CAL_TYPE' => $entityType, 'OWNER_ID' => $entityId, 'DESCRIPTION' => isset($arFields['DESCRIPTION']) ? $arFields['DESCRIPTION'] : '', 'SECTIONS' => $sectionId, 'ACCESSIBILITY' => isset($arFields['ACCESSIBILITY']) ? $arFields['ACCESSIBILITY'] : 'busy', 'IMPORTANCE' => isset($arFields['IMPORTANCE']) ? $arFields['IMPORTANCE'] : 'normal', "REMIND" => is_array($arFields['REMIND']) ? $arFields['REMIND'] : array(), "RRULE" => is_array($arFields['RRULE']) ? is_array($arFields['RRULE']) : array(), "VERSION" => isset($arFields['VERSION']) ? intVal($arFields['VERSION']) : 1, "PRIVATE_EVENT" => !!$arFields['PRIVATE_EVENT']);
$arNewFields["DATE_FROM"] = $arFields['DATE_FROM'];
$arNewFields["DATE_TO"] = $arFields['DATE_TO'];
$arNewFields["TZ_FROM"] = $arFields['TZ_FROM'];
$arNewFields["TZ_TO"] = $arFields['TZ_TO'];
$arNewFields["SKIP_TIME"] = $arFields['SKIP_TIME'];
if ($arNewFields["SKIP_TIME"]) {
$arNewFields["DATE_TO"] = CCalendar::Date(CCalendar::Timestamp($arNewFields['DATE_TO']) - CCalendar::GetDayLen(), false);
}
if (!empty($arFields['PROPERTY_REMIND_SETTINGS'])) {
$ar = explode("_", $arFields["PROPERTY_REMIND_SETTINGS"]);
if (count($ar) == 2) {
$arNewFields["REMIND"][] = array('type' => $ar[1], 'count' => floatVal($ar[0]));
}
}
if (!empty($arFields['PROPERTY_ACCESSIBILITY'])) {
$arNewFields["ACCESSIBILITY"] = $arFields['PROPERTY_ACCESSIBILITY'];
}
if (!empty($arFields['PROPERTY_IMPORTANCE'])) {
$arNewFields["IMPORTANCE"] = $arFields['PROPERTY_IMPORTANCE'];
}
if (!empty($arFields['PROPERTY_LOCATION'])) {
$arNewFields["LOCATION"] = CCalendar::UnParseTextLocation($arFields['PROPERTY_LOCATION']);
}
if (!empty($arFields['DETAIL_TEXT'])) {
$arNewFields["DESCRIPTION"] = $arFields['DETAIL_TEXT'];
}
$arNewFields["DESCRIPTION"] = CCalendar::ClearExchangeHtml($arNewFields["DESCRIPTION"]);
if (isset($arFields["PROPERTY_PERIOD_TYPE"]) && in_array($arFields["PROPERTY_PERIOD_TYPE"], array("DAILY", "WEEKLY", "MONTHLY", "YEARLY"))) {
$arNewFields['RRULE']['FREQ'] = $arFields["PROPERTY_PERIOD_TYPE"];
$arNewFields['RRULE']['INTERVAL'] = $arFields["PROPERTY_PERIOD_COUNT"];
if (!isset($arNewFields['DT_LENGTH']) && !empty($arFields['PROPERTY_EVENT_LENGTH'])) {
$arNewFields['DT_LENGTH'] = intval($arFields['PROPERTY_EVENT_LENGTH']);
} else {
$arNewFields['DT_LENGTH'] = $arFields['DT_TO_TS'] - $arFields['DT_FROM_TS'];
}
if ($arNewFields['RRULE']['FREQ'] == "WEEKLY" && !empty($arFields['PROPERTY_PERIOD_ADDITIONAL'])) {
$arNewFields['RRULE']['BYDAY'] = array();
$bydays = explode(',', $arFields['PROPERTY_PERIOD_ADDITIONAL']);
foreach ($bydays as $day) {
$day = CCalendar::WeekDayByInd($day, false);
if ($day !== false) {
$arNewFields['RRULE']['BYDAY'][] = $day;
}
}
$arNewFields['RRULE']['BYDAY'] = implode(',', $arNewFields['RRULE']['BYDAY']);
}
if (isset($arFields['PROPERTY_PERIOD_UNTIL'])) {
$arNewFields['RRULE']['UNTIL'] = $arFields['PROPERTY_PERIOD_UNTIL'];
} else {
$arNewFields['RRULE']['UNTIL'] = $arFields['DT_TO_TS'];
}
}
$eventId = CCalendar::SaveEvent(array('arFields' => $arNewFields, 'userId' => $userId, 'bAffectToDav' => false, 'bSilentAccessMeeting' => true));
self::$silentErrorMode = false;
return $eventId;
}