Giter VIP home page Giter VIP logo

Comments (9)

drmmr763 avatar drmmr763 commented on May 27, 2024 1

Just a +1 on this feature request.

I actually already have a code base which implements https://github.com/simshaun/recurr's library and I have stored RRULE strings from that. Now I'm trying to add iCal to that and it would be great if I could just take my existing strings and parse them into iCal's ReccuranceRule object.

from ical.

markuspoerschke avatar markuspoerschke commented on May 27, 2024

I think we need something that can parse content from an ICS file into the corresponding PHP objects. The idea behind this library is to work with PHP objects rather than plain text. I would prefer a method like $myRecurrenceRule = RecurrenceRule::createFromString('FREQ=WEEKLY;INTERVAL=1;COUNT=30').

from ical.

cmfcmf avatar cmfcmf commented on May 27, 2024

I think we need something that can parse content from an ICS file into the corresponding PHP objects. The idea behind this library is to work with PHP objects rather than plain text. I would prefer a method like $myRecurrenceRule = RecurrenceRule::createFromString('FREQ=WEEKLY;INTERVAL=1;COUNT=30').

Yes, something along these lines would be great.

from ical.

LiviuChirca avatar LiviuChirca commented on May 27, 2024

I've been modified a little bit to allow me to use a string RRULE;

In property.php:

$line .= ':' . $this->value->getEscapedValue();

change to

        if($this->name != "RRULE")
            $line .= ':' . $this->value->getEscapedValue();
        else
            $line .= ':' . stripslashes($this->value->getEscapedValue());

and in Event.php

    public function setRecurrenceRule(RecurrenceRule $recurrenceRule)
    {
        $this->recurrenceRule = $recurrenceRule;

        return $this;
    }

change to

    public function setRecurrenceRule($recurrenceRule)
    {
        $this->recurrenceRule = $recurrenceRule;
        return $this;
    }

and when you set the RRULE to the event object, just do it:

$vEvent->setRecurrenceRule("FREQ=DAILY;INTERVAL=1;COUNT=5");

just make sure your RRULE is already validated.

from ical.

Ydalb avatar Ydalb commented on May 27, 2024

Maybe we could use the excellent work of https://github.com/simshaun/recurr ?

from ical.

markuspoerschke avatar markuspoerschke commented on May 27, 2024

@Ydalb having a library to integrate into this project would be nice. I will check how I can integrate that into this library!

from ical.

ankurk91 avatar ankurk91 commented on May 27, 2024

I would be nice to have this feature baked in into v2.0

from ical.

williamdes avatar williamdes commented on May 27, 2024

Maybe we could use the excellent work of https://github.com/simshaun/recurr ?

@markuspoerschke I need to have rrule (https://icalendar.org/rrule-tool.html) on my Events. Are contributions welcome to bake this cool lib (simshaun/recurr) into this one ?

from ical.

maskedjellybean avatar maskedjellybean commented on May 27, 2024

I'd like to see this method too. In the meanwhile I have this absurd bit of code in case it's helpful for others. $date['rrule'] is an RRULE string, and $iCalendarEvent is a \Eluceo\iCal\Component\Event object.

// Even though we already have an RRULE string,
// the library doesn't allow us to simply use it.
// We have to deconstruct it, create a RecurrenceRule object,
// then have the object reconstruct the string. Phew.
// See: https://github.com/markuspoerschke/iCal/issues/37
$rruleStr = $date['rrule'];
$recurrenceRule = new RecurrenceRule();
$rruleSplit = explode(';', $rruleStr);
foreach ($rruleSplit as $rruleProp) {
  if (str_contains($rruleProp, 'FREQ')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setFreq($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'INTERVAL')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setInterval($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYSECOND')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setBySecond($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYMINUTE')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setByMinute($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYHOUR')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setByHour($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYDAY')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setByDay($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYMONTHDAY')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setByMonthDay($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYYEARDAY')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setByYearDay($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYWEEKNO')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setByWeekNo($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYMONTH')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setByMonth($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'BYSETPOS')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setBySetPos($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'WKST')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setWkst($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'UNTIL')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setUntil($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'COUNT')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setCount($rrulePropVal);
  }
  else if (str_contains($rruleProp, 'INTERVAL')) {
    $rrulePropVal = explode('=', $rruleProp)[1];
    $recurrenceRule->setInterval($rrulePropVal);
  }
}

$iCalendarEvent->addRecurrenceRule($recurrenceRule);

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.