GiovanniSalmeri/yellow-diary

iCalendar: Invalid information if event goes past midnight.

Closed this issue · 9 comments

Hello Giovanni,

there is a problem with the iCalendar files when an event goes past midnight. I suspect it's because there is no end date specified there.

Yes, I am aware of the problem... When I wrote this little extension, the first use was for conferences and lectures in a University, which obviously never go past midnight (and never span several days without breaks). But before a future global overhaul I could write a little patch that at least could cope with the case of an event that goes past midnight. The logic could be: when the end time precedes the start time, it is interpreted as belonging to the following day. Would this be useful to you?

That would be an acceptable work around. 😃

Try changing line 58 like this:

$eventTime = strtotime($event[0]." ".$event[2]) + (strcmp($event[1], $event[2])>0 ? 86400 : 0);

And line 272 like this:

$end = gmdate($timeFormat, strtotime($event[0]." ".$event[2]) +  (strcmp($event[1], $event[2])>0 ? 86400 : 0));

This very simple patch works only if hours are always written with two digits (for example 09:30, not 9:30). In order to regenerate the wrong iCal files, it is sufficient to delete them. Not tested, should work...

Edit: corrected the obviously wrong code...

pftnhr commented

It works like a charm, thank you very much!

pftnhr commented

Rejoiced too soon. Now the ICS works but the website shows the end date as the event date.

Now the ICS works but the website shows the end date as the event date.

Sorry, I will double-check as soon as possible!

Please change also line 63 like this:

$getDate = getdate(strtotime($event[0]));
pftnhr commented

Thanks a lot, it works!

If you're interested, take a look at: https://www.ckb-ev.de/veranstaltungen/

I am glad it works as intended. Your page is very nice, thank you!