Giter VIP home page Giter VIP logo

Comments (12)

KevinHoughton avatar KevinHoughton commented on May 28, 2024 1

@markuspoerschke I've fixed it. I've added the extra code from example 5 and made my events using datetime.

 public function getIcal($token = null)
    {
        $user = $this->userRepository->getByToken($token);

        $vCalendar = new Calendar('www.onderwijsonline.nl');
        $vCalendar->setPublishedTTL('PT15M');

        // set default timezone (PHP 5.4)
        $tz  = 'Europe/Amsterdam';
        $dtz = new \DateTimeZone($tz);
        date_default_timezone_set($tz);

        // 2. Create timezone rule object for Daylight Saving Time
        $vTimezoneRuleDst = new TimezoneRule(TimezoneRule::TYPE_DAYLIGHT);
        $vTimezoneRuleDst->setTzName('CEST');
        $vTimezoneRuleDst->setDtStart(new \DateTime('1981-03-29 02:00:00', $dtz));
        $vTimezoneRuleDst->setTzOffsetFrom('+0100');
        $vTimezoneRuleDst->setTzOffsetTo('+0200');
        $dstRecurrenceRule = new RecurrenceRule();
        $dstRecurrenceRule->setFreq(RecurrenceRule::FREQ_YEARLY);
        $dstRecurrenceRule->setByMonth(3);
        $dstRecurrenceRule->setByDay('-1SU');
        $vTimezoneRuleDst->setRecurrenceRule($dstRecurrenceRule);

        // 3. Create timezone rule object for Standard Time
        $vTimezoneRuleStd = new TimezoneRule(TimezoneRule::TYPE_STANDARD);
        $vTimezoneRuleStd->setTzName('CET');
        $vTimezoneRuleStd->setDtStart(new \DateTime('1996-10-27 03:00:00', $dtz));
        $vTimezoneRuleStd->setTzOffsetFrom('+0200');
        $vTimezoneRuleStd->setTzOffsetTo('+0100');
        $stdRecurrenceRule = new RecurrenceRule();
        $stdRecurrenceRule->setFreq(RecurrenceRule::FREQ_YEARLY);
        $stdRecurrenceRule->setByMonth(10);
        $stdRecurrenceRule->setByDay('-1SU');
        $vTimezoneRuleStd->setRecurrenceRule($stdRecurrenceRule);

        // 4. Create timezone definition and add rules
        $vTimezone = new Timezone($tz);
        $vTimezone->addComponent($vTimezoneRuleDst);
        $vTimezone->addComponent($vTimezoneRuleStd);
        $vCalendar->setTimezone($vTimezone);

        if (!is_null($user)) {

            /**
             * Calendar events
             */
            $events = $this->calendarRepository->getEventsForUser($user->id, Carbon::now()->subWeeks(2), Carbon::now()->addWeeks(6));
            foreach ($events as $event) {

                $vEvent = new Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(new \DateTime(Carbon::parse($event['start']), $dtz))
                    ->setDtEnd(new \DateTime(Carbon::parse($event['end'])))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setUrl($event['href'])
                    ->setDescription($event['description'])
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }

            /**
             * Project events
             */
            $events = $this->calendarRepository->getEventsForProjects($user->id, null, null);

            foreach ($events as $event) {
                $vEvent = new Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(new \DateTime(Carbon::parse($event['start']), $dtz))
                    ->setDtEnd(new \DateTime(Carbon::parse($event['end'])))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setUrl($event['href'])
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }

            /**
             * Timetable events
             */
            $events = $this->calendarRepository->getEventsForTimetables($user->id, Carbon::now()->startOfWeek(), Carbon::now()->startOfWeek()->addWeeks(4));
            foreach ($events as $event) {
                $vEvent = new Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(new \DateTime(Carbon::parse($event['start']), $dtz))
                    ->setDtEnd(new \DateTime(Carbon::parse($event['end'])))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }
        }

        header('Content-Type: text/calendar; charset=utf-8');
        header('Content-Disposition: inline; filename=onderwijsonline.ics');

        return $vCalendar->render();
    }

from ical.

KevinHoughton avatar KevinHoughton commented on May 28, 2024

Test case: https://beta.onderwijsonline.nl/calendar/ical/eyJpdiI6ImZqU0hPZlwvcnIrMmNubWRadE01N1NnPT0iLCJ2YWx1ZSI6IjB2QzhabUJVQ3VreDNFbGtyWHhNaGc9PSIsIm1hYyI6ImU5YmMzNGZmNzY3NDMwNjk3OTk4ZTA2ZTVlOWJmYzYxYmMxOGY5ZjU2MDFmYmZlOTVkMGE4OTM3ZGM4MjEwYzQifQ==

from ical.

markuspoerschke avatar markuspoerschke commented on May 28, 2024

There is no DTSTART within the generated ical file (the file in the issue description above). Which version do you use? Maybe this is fixed for all day events in #83 ?

from ical.

KevinHoughton avatar KevinHoughton commented on May 28, 2024

Version that is being used is: 0.10. I just updated to 0.11.* on the servers, which is on the url I mentioned above. But still no luck on Outlook.

from ical.

KevinHoughton avatar KevinHoughton commented on May 28, 2024

Could there be an issue in the protocol that is being used? In every example outlook uses webcal://, not https:// or http://.

from ical.

fh-jashmore avatar fh-jashmore commented on May 28, 2024

You said this is being output to a url? Are there any other headers?

from ical.

KevinHoughton avatar KevinHoughton commented on May 28, 2024

@fh-jashmore all headers are set as said in the documentation.

header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=onderwijsonline.ics');

from ical.

KevinHoughton avatar KevinHoughton commented on May 28, 2024

What's the progress for this issue? @markuspoerschke

from ical.

markuspoerschke avatar markuspoerschke commented on May 28, 2024

@KevinHoughton I just tested the URL above and the events are working in Appleโ€™s calendar. There I can see the events. Sadly I have no access to Outlook where I could test your file. To mee it looks good. I will attach a screenshot how it looks like to me.

ical

from ical.

markuspoerschke avatar markuspoerschke commented on May 28, 2024

Did you try to simplify the calendar file for outlook? Mayb you can first start with a simple event with title and time only. And later on you could enable timezone etc. Maybe that could be a possibility to dissect and finally find the problem.

from ical.

fh-jashmore avatar fh-jashmore commented on May 28, 2024

I spent around 8 hours trying to duplicate outlook files that were working with outlook. I couldn't figure it out. And I tried simple stuff. I'm not 100% sure its the calendar file.

from ical.

KevinHoughton avatar KevinHoughton commented on May 28, 2024

Maybe this helps?

https://icalendar.org/validator.html?url=https://beta.onderwijsonline.nl/calendar/ical/eyJpdiI6InIzZ3lXbjcwTTBRU3RpNE91aDRVdGc9PSIsInZhbHVlIjoiSHo4OUcxbGZjUVJxNHlzNndnK1NKQT09IiwibWFjIjoiZDAwY2JlMjM1NDI1OTk0OWVmYjViNzQzNmJkM2EwM2VkMTY1M2QwNmEyZThiNzI0MTJhNmM4YjFlMmZlY2UxNSJ9

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.