diff --git a/inc/tz/expand.php b/inc/tz/expand.php index c5f5c1ba..89a8c215 100644 --- a/inc/tz/expand.php +++ b/inc/tz/expand.php @@ -46,6 +46,7 @@ define( 'DEBUG_EXPAND', false ); * @param object $vResource is a VCALENDAR with a VTIMEZONE containing components needing expansion * @param object $range_start A RepeatRuleDateTime which is the beginning of the range for events. * @param object $range_end A RepeatRuleDateTime which is the end of the range for events. +* @param int $offset_from The offset from UTC in seconds at the onset time. * * @return array of onset datetimes with UTC from/to offsets */ @@ -60,8 +61,6 @@ function expand_timezone_onsets( vCalendar $vResource, RepeatRuleDateTime $range $is_date = false; $has_repeats = false; $zone_tz = $vtz->GetPValue('TZID'); - $range_start->setTimeZone($zone_tz); - $range_end->setTimeZone($zone_tz); foreach( $components AS $k => $comp ) { if ( DEBUG_EXPAND ) { @@ -73,8 +72,14 @@ function expand_timezone_onsets( vCalendar $vResource, RepeatRuleDateTime $range } $dtstart_prop = $comp->GetProperty('DTSTART'); if ( !isset($dtstart_prop) ) continue; - $dtstart_prop->SetParameterValue('TZID',$zone_tz); $dtstart = new RepeatRuleDateTime( $dtstart_prop ); + $dtstart->setTimeZone('UTC'); + $offset_from = $comp->GetPValue('TZOFFSETFROM'); + $offset_from = (($offset_from / 100) * 3600) + ((abs($offset_from) % 100) * 60 * ($offset_from < 0 ? -1 : 0)); + $offset_from *= -1; + $offset_from = "$offset_from seconds"; + dbg_error_log( 'tz/update', "%s of offset\n", $offset_from); + $dtstart->modify($offset_from); $is_date = $dtstart->isDate(); $instances[$dtstart->UTC('Y-m-d\TH:i:s\Z')] = $comp; $rrule = $comp->GetProperty('RRULE'); diff --git a/testing/tests/timezone/5040-expand.result b/testing/tests/timezone/5040-expand.result index e70636e3..8565d293 100644 --- a/testing/tests/timezone/5040-expand.result +++ b/testing/tests/timezone/5040-expand.result @@ -12,133 +12,133 @@ Content-Type: application/xml; charset="utf-8" Gregorian NZST - 2011-04-02T15:00:00Z + 2011-04-03T14:00:00Z +13:00 +12:00 NZDT - 2011-09-24T14:00:00Z + 2011-09-25T14:00:00Z +12:00 +13:00 NZST - 2012-03-31T15:00:00Z + 2012-04-01T14:00:00Z +13:00 +12:00 NZDT - 2012-09-29T14:00:00Z + 2012-09-30T14:00:00Z +12:00 +13:00 NZST - 2013-04-06T15:00:00Z + 2013-04-07T14:00:00Z +13:00 +12:00 NZDT - 2013-09-28T14:00:00Z + 2013-09-29T14:00:00Z +12:00 +13:00 NZST - 2014-04-05T15:00:00Z + 2014-04-06T14:00:00Z +13:00 +12:00 NZDT - 2014-09-27T14:00:00Z + 2014-09-28T14:00:00Z +12:00 +13:00 NZST - 2015-04-04T15:00:00Z + 2015-04-05T14:00:00Z +13:00 +12:00 NZDT - 2015-09-26T14:00:00Z + 2015-09-27T14:00:00Z +12:00 +13:00 NZST - 2016-04-02T15:00:00Z + 2016-04-03T14:00:00Z +13:00 +12:00 NZDT - 2016-09-24T14:00:00Z + 2016-09-25T14:00:00Z +12:00 +13:00 NZST - 2017-04-01T15:00:00Z + 2017-04-02T14:00:00Z +13:00 +12:00 NZDT - 2017-09-23T14:00:00Z + 2017-09-24T14:00:00Z +12:00 +13:00 NZST - 2018-03-31T15:00:00Z + 2018-04-01T14:00:00Z +13:00 +12:00 NZDT - 2018-09-29T14:00:00Z + 2018-09-30T14:00:00Z +12:00 +13:00 NZST - 2019-04-06T15:00:00Z + 2019-04-07T14:00:00Z +13:00 +12:00 NZDT - 2019-09-28T14:00:00Z + 2019-09-29T14:00:00Z +12:00 +13:00 NZST - 2020-04-04T15:00:00Z + 2020-04-05T14:00:00Z +13:00 +12:00 NZDT - 2020-09-26T14:00:00Z + 2020-09-27T14:00:00Z +12:00 +13:00 NZST - 2021-04-03T15:00:00Z + 2021-04-04T14:00:00Z +13:00 +12:00 NZDT - 2021-09-25T14:00:00Z + 2021-09-26T14:00:00Z +12:00 +13:00 diff --git a/testing/tests/timezone/5041-expand.result b/testing/tests/timezone/5041-expand.result index a3298a14..b85119d5 100644 --- a/testing/tests/timezone/5041-expand.result +++ b/testing/tests/timezone/5041-expand.result @@ -18,7 +18,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2009-11-01T07:00:00Z + 2009-11-01T06:00:00Z -04:00 -05:00 @@ -30,7 +30,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2010-11-07T07:00:00Z + 2010-11-07T06:00:00Z -04:00 -05:00 @@ -42,7 +42,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2011-11-06T07:00:00Z + 2011-11-06T06:00:00Z -04:00 -05:00 @@ -54,7 +54,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2012-11-04T07:00:00Z + 2012-11-04T06:00:00Z -04:00 -05:00 @@ -66,7 +66,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2013-11-03T07:00:00Z + 2013-11-03T06:00:00Z -04:00 -05:00 @@ -78,7 +78,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2014-11-02T07:00:00Z + 2014-11-02T06:00:00Z -04:00 -05:00 @@ -90,7 +90,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2015-11-01T07:00:00Z + 2015-11-01T06:00:00Z -04:00 -05:00 @@ -102,7 +102,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2016-11-06T07:00:00Z + 2016-11-06T06:00:00Z -04:00 -05:00 @@ -114,7 +114,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2017-11-05T07:00:00Z + 2017-11-05T06:00:00Z -04:00 -05:00 @@ -126,7 +126,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2018-11-04T07:00:00Z + 2018-11-04T06:00:00Z -04:00 -05:00 @@ -138,7 +138,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2019-11-03T07:00:00Z + 2019-11-03T06:00:00Z -04:00 -05:00 @@ -150,7 +150,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2020-11-01T07:00:00Z + 2020-11-01T06:00:00Z -04:00 -05:00 @@ -162,7 +162,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2021-11-07T07:00:00Z + 2021-11-07T06:00:00Z -04:00 -05:00 diff --git a/testing/tests/timezone/5042-expand.result b/testing/tests/timezone/5042-expand.result index 8156f1a9..af9c6c8b 100644 --- a/testing/tests/timezone/5042-expand.result +++ b/testing/tests/timezone/5042-expand.result @@ -18,7 +18,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2011-11-06T07:00:00Z + 2011-11-06T06:00:00Z -04:00 -05:00 @@ -30,7 +30,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2012-11-04T07:00:00Z + 2012-11-04T06:00:00Z -04:00 -05:00 diff --git a/testing/tests/timezone/5043-expand.result b/testing/tests/timezone/5043-expand.result index 70e5e037..6cf071da 100644 --- a/testing/tests/timezone/5043-expand.result +++ b/testing/tests/timezone/5043-expand.result @@ -18,7 +18,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2014-11-02T07:00:00Z + 2014-11-02T06:00:00Z -04:00 -05:00 @@ -30,7 +30,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2015-11-01T07:00:00Z + 2015-11-01T06:00:00Z -04:00 -05:00 @@ -42,7 +42,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2016-11-06T07:00:00Z + 2016-11-06T06:00:00Z -04:00 -05:00 @@ -54,7 +54,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2017-11-05T07:00:00Z + 2017-11-05T06:00:00Z -04:00 -05:00 @@ -66,7 +66,7 @@ Content-Type: application/xml; charset="utf-8" EST - 2018-11-04T07:00:00Z + 2018-11-04T06:00:00Z -04:00 -05:00