Giter VIP home page Giter VIP logo

Comments (6)

kaju74 avatar kaju74 commented on May 27, 2024 1

Yep - this fixes the problem. Didn't noticed that there's a new version avaiable ;-)

Thank you & keep up this great work...

kaju

from ical.

markuspoerschke avatar markuspoerschke commented on May 27, 2024

Guten Morgen Marc,

how does the code look like that generates the iCal file? Do you have an example?

Maybe you can try to turn of the timezone because you have an all day event:

$vEvent->setUseTimezone(false);

from ical.

kaju74 avatar kaju74 commented on May 27, 2024

HI.

This makes no difference....so here's my full code:

`
public function ical($id)
{
// try to find user by id
$user = User::...;

// create new calendar
$calendar = new Calendar('URL');
$calendar->setName('Calendar Name');
$calendar->setCalId(hash('ripemd160', $user->id));
$calendar->setDescription('Calender Description');
$calendar->setPublishedTTL('PT30M');

// set default timezone
$tz = config('app.timezone');
$dtz = new \DateTimeZone($tz);

// create daylight recurrence role
$daylight_recurrence = new RecurrenceRule();
$daylight_recurrence->setFreq(RecurrenceRule::FREQ_YEARLY);
$daylight_recurrence->setByMonth(3);
$daylight_recurrence->setByDay('-1SU');

// create daylight timezone rule
$daylight_timezone = new TimezoneRule(TimezoneRule::TYPE_DAYLIGHT);
$daylight_timezone->setTzName('CEST');
$daylight_timezone->setDtStart(new DateTime('1981-03-29 02:00:00', $dtz));
$daylight_timezone->setTzOffsetFrom('+0100');
$daylight_timezone->setTzOffsetTo('+0200');
$daylight_timezone->setRecurrenceRule($daylight_recurrence);

// create standard recurrence role
$standard_recurrence = new RecurrenceRule();
$standard_recurrence->setFreq(RecurrenceRule::FREQ_YEARLY);
$standard_recurrence->setByMonth(10);
$standard_recurrence->setByDay('-1SU');

// create standard timezone rule
$standard_timezone = new TimezoneRule(TimezoneRule::TYPE_STANDARD);
$standard_timezone->setTzName('CET');
$standard_timezone->setDtStart(new DateTime('1996-10-27 03:00:00', $dtz));
$standard_timezone->setTzOffsetFrom('+0200');
$standard_timezone->setTzOffsetTo('+0100');
$standard_timezone->setRecurrenceRule($standard_recurrence);

// create timezone
$timezone = new Timezone($tz);
$timezone->addComponent($daylight_timezone);
$timezone->addComponent($standard_timezone);
$calendar->setTimezone($timezone);

/**
 * Iterate through all items.
 *
 * @var Event $item
 */
foreach ($items as $item) {

    // create new calendar
    $event = new \Eluceo\iCal\Component\Event();

    // set summary
    $event->setSummary($item->title);

    // set start- and end date/time
    $event->setDtStart($item->start_at);
    $event->setDtEnd($item->end_at);

    // distribute time part?
    $event->setNoTime(!(
        ($item->start_at) && ($item->start_at->format('H:i') !== '00:00') ||
        ($item->end_at) && ($item->end_at->format('H:i') !== '00:00')
    ));

    // location info available?
    if ($location = $item->location) {
        // add geo location?
        $geo = $location->latitude && $location->longitude
            ? sprintf('%s;%s', $location->latitude, $location->longitude)
            : null;

        // add location to event
        $event->setLocation($location->name, $location->name, $geo);
    }

    // add timezone support
    $event->setUseTimezone(true);

    // add event to calendar
    $calendar->addComponent($event);

}

// set http header
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="iCal.ics"');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

// return rendered calendar
return $calendar->render();

}
`

Best regards (Liebe Grüße),
Marc

from ical.

kaju74 avatar kaju74 commented on May 27, 2024

Hi.

Any progress here or should I try to fix it myself, if you haven't time?

Best regards,
Marc

from ical.

markuspoerschke avatar markuspoerschke commented on May 27, 2024

@kaju74 please feel free to contribute a fix if you can. This is an open source project that I am maintaining in my freetime. I am happy about every contribution.

Regarding your generated iCal file. The DTSTART;TZID=Europe/Berlin;VALUE=DATE:20170630 property cotains the timezone. That was removed in newer version of this library. Can you check if you can update to a newer version?

from ical.

markuspoerschke avatar markuspoerschke commented on May 27, 2024

Funnily in this issue it is reported that the event is to short and in #83 @Seldaek found out that events are to long.

from ical.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.