Comments (9)
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.
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.
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.
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.
Maybe we could use the excellent work of https://github.com/simshaun/recurr ?
from ical.
@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.
I would be nice to have this feature baked in into v2.0
from ical.
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.
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)
- Compatibility with PHP 8.1 HOT 1
- Adding custom Calendar properties is not possible without code duplication HOT 4
- Calendar app on the Mac does not accept this ics. HOT 6
- Geographic position is always NULL HOT 1
- No exist Method property in EventFactory HOT 4
- The organizer's e-mail changes the @ to %40 HOT 2
- ICS and calendar agent causing a lot of requests for past events on my asp.net mvc endpoint
- eluceo/ical 2.7.0 conflicts with php 7.4.6 HOT 1
- Invalid iCal generated when DateTimeZone is UTC
- How to cancel an event
- iCal in one line HOT 2
- Cannot set BYMONTHDAY to a comma-separated list
- UTC Format sometimes not recognized on some calendars HOT 2
- Set organizer not working properly
- Reporting a vulnerability
- SSL certificate expired
- Not working with Outlook Calendar
- [FEATURE] Enable TimeSpan work with only start Time
- Psalm error when trying to create a date object
- Documentation link is broken HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ical.