Jump to content

Recommended Posts

 

Hey everyone,

 

I am working on a simple event listing out of a mysql table and I am trying to get an algorithm down for displaying recurring and one time events in the same listing in date order.

 

The only thought I have had thus far is to do a step through for every day and see if it matches criteria (between start and end of recurring dates, not excluded), etc, but I think there has to be a better way to do it.

 

I am always showing next X days (7 days on one portion of the site, "full list" goes to 30 days in advance, no other views).

 

Any thoughts would be appreciated, thanks.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/36825-recurring-events-vs-one-time-events/
Share on other sites

  • 4 weeks later...
  • 3 weeks later...

At a guess..

 

Calculate the dates of your recursions, then offset them accordingly with one time dates.

 

Well, the main problem is with things that in theory will repeat forever (weekly meetings), so it is not quite that simple. I have thought about using a model that states the day of the week and indicates it to repeat, but then for every date that I cycle through, I would have to find the number to correspond to that day of the week and search.

 

Has anybody seen how this is constructed in calendar programs that might have a good solution?

 

I actually did something sort of like this and it worked, but not saying its the best way. Basically I created the event and in another table I listed out all the dates that the event would occur on. You can see from the attachment that it handled everything that outlook handled. I spliced together different parts of this web page so you could see the different options but a real basic table structure that I used was....

 

Event_ID

Event_Name

Event_RecurrencePattern

 

EventDate_ID

EventDate_EventID

EventDate_DateTime

 

This way you can easily list out all the dates.

 

[attachment deleted by admin]

At a guess..

 

Calculate the dates of your recursions, then offset them accordingly with one time dates.

 

Well, the main problem is with things that in theory will repeat forever (weekly meetings), so it is not quite that simple. I have thought about using a model that states the day of the week and indicates it to repeat, but then for every date that I cycle through, I would have to find the number to correspond to that day of the week and search.

 

Has anybody seen how this is constructed in calendar programs that might have a good solution?

 

It still falls back to what I said:

Calculate the dates of your recursive appointments, then compare them to the one time events.

Let's take a weekly meeting on Wednesdays:

<?php

if (date('D', $recursiveMeeting) == date('D', time())) echo "Today has a weekly meeting.";

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.