Skip to content

Commit

Permalink
Merge branch 'MDL-75627_m400_v1' of https://github.com/sbourget/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_400_STABLE
  • Loading branch information
sarjona committed Nov 17, 2022
2 parents 9c9b10b + 3bb3afd commit 2700e9b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions calendar/lib.php
Expand Up @@ -3072,11 +3072,21 @@ function calendar_import_events_from_ical(iCalendar $ical, int $subscriptionid =
\core_php_time_limit::raise(300);
}

// Start with a safe default timezone.
$timezone = 'UTC';

// Grab the timezone from the iCalendar file to be used later.
if (isset($ical->properties['X-WR-TIMEZONE'][0]->value)) {
$timezone = $ical->properties['X-WR-TIMEZONE'][0]->value;
} else {
$timezone = 'UTC';

} else if (isset($ical->properties['PRODID'][0]->value)) {
// If the timezone was not found, check to se if this is MS exchange / Office 365 which uses Windows timezones.
if (strncmp($ical->properties['PRODID'][0]->value, 'Microsoft', 9) == 0) {
if (isset($ical->components['VTIMEZONE'][0]->properties['TZID'][0]->value)) {
$tzname = $ical->components['VTIMEZONE'][0]->properties['TZID'][0]->value;
$timezone = IntlTimeZone::getIDForWindowsID($tzname);
}
}
}

$icaluuids = [];
Expand Down

0 comments on commit 2700e9b

Please sign in to comment.