Giter Site home page Giter Site logo

Looking for a way to add DTEND about php-rrule HOT 1 CLOSED

roycw avatar roycw commented on August 25, 2024
Looking for a way to add DTEND

from php-rrule.

Comments (1)

rlanvin avatar rlanvin commented on August 25, 2024

Hello,

Thanks for your message. So DTEND indicates the end of an event, and is not part of the RRULE property. Since every event in the recurrence is supposed to be the same duration, it doesn't impact the recurrence,. I am not aware of a way in the RFC 5545 to describe a recurring event, with some occurrences having a different DTEND.

Therefore in theory you can just calculate the DTEND by adding the duration of the event to the occurrence start date generated by the library. Years ago I wrote a small convenience wrapper with an Event class and a Proxy class as a proof of concept (here - note the branch is outdated). The goal is exactly to do that, simply adding the duration automatically.

my issue is that i dont know which occurrence was created with each rule... RSet includes alot of rules.

That's indeed not really possible, but I'm not sure - what would be your use case for this? Are your including rules referring to different events maybe? The RSet is modelled after the "recurrence set" described in RFC 5545 and is supposed to be used to combine multiple RRULE, RDATE and EXDATE for the same event. Therefore you can apply the same technique describe above to just add the duration to each occurrence and have your DTEND.

If you're trying to use it for multiple different events... then it's indeed a bit tricky, because internally RSet works with DateTime objects (returned by RRule). If you wanted to "track" what occurrence comes from what rule, it would need to work with a higher level object containing not only the DateTime but also a reference to the rule that generated it (or the duration itself, to calculate the dtend). It might be possible to build on the PoC from the branch I linked above. Instead of giving RRule objects to RSet, using proxy class that implements the right interface and returns custom objects instead of DateTime, but those objects need to be comparable with each other like DateTime so RSet can sort the occurrences (and exclude ExDate...). Again, maybe possible, but not really designed to work like that.

Another possible approach I guess is to simply implement your own "event set" class so you can keep track of each DTEND for each occurrence generated. Internally RSet is using standard heap and iterators, and the entire logic is less than 100 lines, so it's quite straightforward to replicate.

Hope that helps!

from php-rrule.

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.