Forum Moderators: coopster

Message Too Old, No Replies

Google calendar not recognizing DTEND

         

ro1960

11:28 pm on May 3, 2010 (gmt 0)

10+ Year Member



I have set up a PHP script to generate a .ics calendar file to be added to popular calendar desktop or online programs (Outlook, iCal, Gmail, etc).

I found out that the DTEND parameter is exclusive. This means events ending on 20100505 will show as ending before this date (20100504). Once I discovered this, I added one day to the end date and events display correctly in iCal.

But in Google calendar, it still shows as ending one day earlier. I have found similar questions asked around the web without any answer, though. Any idea how to work around this issue?

I am including the code below:


$query_calendar = "SELECT id, event, body, city, state, country,
DATE_FORMAT(date_start, '%Y%m%d') AS Fdate_start,
DATE_FORMAT(date_end, '%Y%m%d') AS Fdate_end
FROM calendar
WHERE date_start >= '2010-01-01'
AND type='event'
ORDER BY date_start";
$result_calendar = mysql_query($query_calendar)
or die ("Couldn't execute Calendar query.");
?>
BEGIN:VCALENDAR
PRODID:MyNameHere
X-WR-CALNAME:MyNameHere
X-WR-CALDESC:MyNameHere
VERSION:2.0
CALSCALE:GREGORIAN
<?php
while ($row_calendar = mysql_fetch_array($result_calendar))
{
extract($row_calendar);
// here we add one day to the end date because DTEND is exclusive
// meaning it considers the event ends at DTEND 00h00m00s
// not at DTEND 23h59m59s
// otherwise events will show as ending one day earlier in iCal
$tomorrow = strtotime('+1 day', strtotime($Fdate_end));
$Fdtend = date('Ymd', $tomorrow);

$h_event = html_entity_decode($event, ENT_QUOTES, "UTF-8");
$h_city = html_entity_decode($city, ENT_QUOTES, "UTF-8");
$h_country = html_entity_decode($country, ENT_QUOTES, "UTF-8");
?>
BEGIN:VEVENT<?php echo "\n"; ?>
SUMMARY:<?php echo $h_event; ?>
<?php echo "\n"; ?>DTSTART:<?php echo $Fdate_start; ?>
<?php echo "\n"; ?>DTEND:<?php echo $Fdtend; ?>
<?php echo "\n"; ?>LOCATION:<?php echo $h_city; if($state) { echo ", ".$state; } echo " - ".$h_country; ?>
<?php echo "\n"; ?>UID:<?php echo $id; ?>
<?php echo "\n"; ?>
URL:http://www.MyNameHere.com/events/<?php echo $id; ?>
<?php echo "\n"; ?>END:VEVENT
<?php
}
?>
END:VCALENDAR

astupidname

12:49 am on May 4, 2010 (gmt 0)

10+ Year Member



Have you tried:

//If I'm right, won't need the next two lines:
//$tomorrow = strtotime('+1 day', strtotime($Fdate_end));
//$Fdtend = date('Ymd', $tomorrow);
//this is presuming that your $Fdate_end is only the y-m-d date
//such as 20100505, without the time after it, add it on:
$Fdtend = $Fdate_end.'T235959Z'; //setting DTEND to the end of the given day, may help?


Just a guess on my part based on what I found for the spec for iCalendar. May want to change that to 'T000000Z' to be before the day actually starts, unsure. But I figure, when in doubt - try to remove any ambiguity which may be present if the time not already stated.

ro1960

8:02 am on May 4, 2010 (gmt 0)

10+ Year Member



I think I may have found the reason. It seems that the Google calendar doesn't actually refreshes when you click on "Refresh". As I let the issue sit overnight after posting my question, I discovered this morning that the events end dates were correct. I will post more info if relevant.