- Модуль: dav
- Путь к файлу: ~/bitrix/modules/dav/classes/general/icalendartimezone.php
- Класс: CDavICalendarTimeZone
- Вызов: CDavICalendarTimeZone::ParseDateTime
static function ParseDateTime($text, $tzid = false, CDavICalendar $calendar = null)
{
$arDateParts = explode('T', $text);
$notZ = true;
if (!empty($text) && count($arDateParts) !== 2)
{
if (!preg_match('/^(d{4}-?d{2}-?d{2})(Z)?$/', $text, $match))
{
return $text;
}
$arDateParts = explode('T', $match[1] . 'T000000' . ($match[2] ?? ''));
}
if (($arDate = self::ParseDate($arDateParts[0])) == null)
{
return $text;
}
if (($arTime = self::ParseTime($arDateParts[1])) == null)
{
return $text;
}
$tzoffset = false;
if ($calendar && $tzid)
{
$tzoffset = self::GetVTimezoneOffset($arDate, $arTime, $tzid, $calendar);
$notZ = false;
}
$result = @mktime($arTime["hours"], $arTime["minutes"], $arTime["seconds"], $arDate["month"], $arDate["mday"], $arDate["year"]);
if ($tzoffset)
{
$result += $tzoffset;
}
/* if ($arTime["zone"] == 'UTC' || $tzoffset !== false)
{
$result = @gmmktime($arTime["hours"], $arTime["minutes"], $arTime["seconds"], $arDate["month"], $arDate["mday"], $arDate["year"]);
if ($tzoffset)
$result -= $tzoffset;
}
else
{
$result = @mktime($arTime["hours"], $arTime["minutes"], $arTime["seconds"], $arDate["month"], $arDate["mday"], $arDate["year"]);
}*/
if ($notZ && ($arTime["zone"] !== 'Local' || $tzid))
{
$result += date('Z');
}
return ($result !== false) ? $result : $text;
}