spatie / calendar-links

Generate add to calendar links for Google, iCal and other calendar systems
https://spatie.be/opensource
MIT License
914 stars 149 forks source link

Google calendar end date is before start date when allDay = true #56

Closed antanova closed 5 years ago

antanova commented 5 years ago

I fixed this temporarily in the Google Generator by adding a day to $link->to like this:

if ($link->allDay) {
    $link->to->add(new \DateInterval('P1D'));
}
alies-dev commented 5 years ago

@antanova Do you use the last version of the package?

Could you please provide some input/output examples so I can easily reproduce it and probably create a fix?

antanova commented 5 years ago

Apologies for the delay. I'm using version 1.2.3. Here's an example that reproduces my issue:

$allDay = true;
$date = new DateTime();
$date->setTimeZone(new DateTimeZone('Europe/London'));
$dateEnd = clone $date;
$dateEnd->add(new DateInterval('P1D')); // issue persists when I add 2 days or don't add anything.

use Spatie\CalendarLinks\Link;
$link = new Link( 'Example title', $date, $dateEnd, $allDay);

?>
<a href="<?php echo $link->google(); ?>">Click here</a>

If I follow the generated link, then the start date in Google is today, and the end date is yesterday.

Screenshot_2019-05-02 Google Calendar - Event details

alies-dev commented 5 years ago

Hey @antanova Thanks for your great report! I've made some fixes and will be happy if you check them out, the branch is 60-fix-allday-links