Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEC-4831 outlook timezone omitted with subscribe #4444

Open
wants to merge 8 commits into
base: fix/TEC-4916-filter-outlook-links
Choose a base branch
from
1 change: 1 addition & 0 deletions readme.txt
Expand Up @@ -234,6 +234,7 @@ Remember to always make a backup of your database and files before updating!

= [6.2.9] TBD =

* Fix - Adjusted how event times and time zones are handled when using Subscribe to Outlook on a single event page. [TEC-4831]
* Tweak - Define image sizes on the List view featured image to avoid Content Layout Shifting. [TEC-4919]
* Tweak - Add new filters to allow customization of the subscribe and export links. [TEC-4916]
* Tweak - Added filters: , `tec_events_subscribe_link_url`, `tec_events_{$slug}_subscribe_link_url`, `tec_events_export_link_visibility`, `tec_events_{$slug}_export_link_visibility`, `tec_events_export_link_url_single`, `tec_events_{$slug}_export_link_url_single`, `tec_events_export_link_url`, `tec_events_{$slug}_export_link_url`
Expand Down
28 changes: 20 additions & 8 deletions src/Tribe/Views/V2/iCalendar/Traits/Outlook_Methods.php
Expand Up @@ -56,7 +56,7 @@ trait Outlook_Methods {
*
* @since 5.16.0
*
* @param string $calendar Whether it's Outlook live or Outlook 365.
* @param string $calendar Whether it's Outlook Live or Outlook 365.
*
* @return string Part of the URL containing the event information.
*/
Expand All @@ -65,20 +65,32 @@ protected function generate_outlook_add_url_parameters( $calendar = 'live' ) {
$event = tribe_get_event();

/**
* If event is an all day event, then adjust the end time.
* Filters whether the time zone offset should be removed from the URL or not.
*
* @var bool $remove_timezone_offset
*/
$remove_timezone_offset = apply_filters( 'tec_remove_outlook_timezone_offset', false );

/**
* If the event is an all-day event, then adjust the end time.
* Using the 'allday' parameter doesn't work well through time zones.
*/
if ( $event->all_day ) {
$end_datetime = Dates::build_date_object( $event->end_date )->format( 'Y-m-d' )
$end_datetime = Dates::build_date_object( $event->end_date, $event->timezone )->format( 'Y-m-d' )
. 'T'
. Dates::build_date_object( $event->start_date )->format( 'H:i:s' );
. Dates::build_date_object( $event->start_date, $event->timezone )->format( 'H:i:s' );
} else {
$end_datetime = Dates::build_date_object( $event->end_date )->format( 'c' );
$end_datetime = substr( $end_datetime, 0, -6 );
$end_datetime = Dates::build_date_object( $event->end_date, $event->timezone )->format( 'c' );

if ( $remove_timezone_offset ) {
$end_datetime = substr( $end_datetime, 0, strlen( $end_datetime ) - 6 );
}
}

$start_datetime = Dates::build_date_object( $event->start_date )->format( 'c' );
$start_datetime = substr( $start_datetime, 0, -6 );
$start_datetime = Dates::build_date_object( $event->start_date, $event->timezone )->format( 'c' );
if ( $remove_timezone_offset ) {
$start_datetime = substr( $start_datetime, 0, strlen( $start_datetime ) - 6 );
}

$params = [
'path' => '/calendar/action/compose',
Expand Down