2

I have submitted this previously but because someone down voted it and said it was already answered, no-one will answer it.

I know there are similar posts here:

but they do not answer my request which is for a practical, simple and real-world example of logic for a recurring calendar setup, without using another framework or tools/scripts other than straight PHP and MySQL.

I do agree that this article http://martinfowler.com/apsupp/recurring.pdf is good, but it is so abstract that I cannot understand it.

I know there are other "Systems that have done this" but this is my own white whale, and I will figure it out at some point - I would just like some help along the way.

So, the question is: how do I build a recurring calendar using PHP and MySQL?

4
  • Looks like you are really scared of down-voting.. :-) Commented Feb 27, 2009 at 14:12
  • I won't downvote you, but your question is so abstract that I cannot understand it :) What is that you wanted to ask, for first? Commented Feb 27, 2009 at 14:14
  • the question is, how do I pull dates from a database, and if (is set to m-w-f) show it on just those dates, unless there is a date that matches in a "exclusion"table then show it... what about other recurrance patterns.... 1st _day of month etc Commented Feb 27, 2009 at 14:26
  • Possible duplicate of PHP Calendar Recurrence Logic Commented Apr 11, 2017 at 6:32

2 Answers 2

1

You should strive to understand the Fowler article. It really does cover it.

The fact of the matter is, this is a hard problem. Editing logic "on the fly" is not something users really want to do. Rather, they want you as a programmer to have anticipated what they'll want to do and provided a rule for it--they don't want to have to figure out how to compute the second Wednesday of the month, for instance.

It sounds like your real problem lies in modeling the recurrence in MySQL. You could use Google's spec, which can be stored in a database and covered on Stack Overflow before. Fowler's piece also provides some good starting points in terms of well-defined classes that can be represented in an RDBMS.

It's a hard problem. And while SO wants you to succeed, we can only lead you to the stream. We can't force you to drink.

Sign up to request clarification or add additional context in comments.

8 Comments

I started as a ADD Visual designer, not coder so fowler's examples are way over my head... is there anything that can help me understand fowler?? an intermediary if you will??
Where do you feel like you fall short in your understanding? Are you not familiar with OO principles? Are the UML diagrams foreign to you? Or are there particular concepts that you don't fully grok? Asking about those specific things would help us help you.
Well, i guess the real issue is, most problems I encounter or scripts I need to create involve taking something that is working and fiddeling with it till it breaks, then I fix it and modify it to my needs for that moment -- I guess that would mean I don't "Understand" any of it [;o)
example - public boolean isOccurring(String eventArg, Date aDate) { ScheduleElement eachSE; ... I get the basic "Idea" of what the pieces are, but don't know what data or veriables go where and how to make it all work together
I would recommend editing your question to focus on those aspects of the Fowler paper, then. You'll get more help with specific questions than the somewhat vague and difficult one you posed.
|
0

For a practical, real-world example of recurring calendar logic, look at your PDA or equivalent.

I got to build a calendar in an intranet application a few years ago and basically copied what my Palm had for recurring options. It made sense to people, so I judged it a success. But it didn't store real clean in the database. My code ended up with lots of careful checks that data was consistent along with various rules to correct things if something looked awry. It helped that we were actively using it as I was developing it. :-)

As far as storage went, the calendar entry involved a flag that indicated if it was part of a recurring series or not. If it wasn't, it was a non-recurring entry. If it was, then editing it had a couple of options, one of which was to break the series at this entry. Recurring entries were put into the database as discrete items; this was a type of denormalization that was done for performance reasons. Amongst other things, it meant that other code that wanted to check the calendar didn't have to worry about recurring items. We solved the "neverending" problem by always requiring an end-date to the series.

Actually setting up the recurring items involved some JavaScript in the UI to control the different settings. The entry in the DB had a combination of values to indicate the scope of the recurrence (e.g. daily, weekly, ...) the recurring step (e.g. 1 week, 2 weeks, ...) and any variation (weekly let you say "Monday, Wednesday, Thursday every week").

Finally, we had some logic that I never got to fully implement that handled timezones and daylight saving. This is difficult, because you have to allow the shift to apply selectively. That is, some calender items will stay in time local to the end-user, others are fixed to a location, and either may or may not shift with daylight saving. I left that company before I got a fix on that problem.

Lastly, I'm replying to this because I didn't see all the other questions. :-) But go read and understand that PDF.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.