On Wed, 2007-03-07 at 23:09 -0500, Jay Parlar wrote: > On 3/7/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > Sorry, I skipped the first step in the reasoning because I thought it > > was obvious. My bad. > > > > Except for events that repeat only yearly, every single one of your > > events is going to occur at least once in any given month. The only > > exceptions will be things like events with monthly repetition on the > > 30th of the month and where you're considering the month of February. > > But that case occurs infrequently enough that you can ignore it. > > > > So, your initial list is *every event*. Then you have a method on the > > Event model that converts that single event + a month and year (i.e. a > > date) into a list of events on particular dates in that month. The > > slight improvement here is to select every event except yearly ones and > > then treat yearly recurrences as special. Which approach is best depends > > on how common yearly events are. > > > > Iterate over your set of events, calling the special method and have > > that method return a list of (date, title) tuples, for example. Then > > merge those lists (iterate and merge in a single list comprehension), > > sort the list and you're ready to put them on a calendar. > > > > Is that clearer? > > > > Ok, my bad, I left one option out of my original model, namely > "NoRepeat", for one-off events. > > But talking this through with you has filled in the blanks. So I think > it stands as follows: > > 1) Select all events that are NoRepeat, and find the ones that are in > the desired month. > 2) Then do everything you said on the set of events that are not > NoRepeat, plus my results from step 1. > > Sound good?
Yep. > > Of course, this is a simplified model. If I want to allow all the > features of a regular calendar app, I'll need to support custom > repeats, like "Every second Thursday", or "Every 5 months on the > 17th". iCal on OS X has a very nice interface for selecting these > custom repeats, I guess I'll try and copy that. The same logic should mostly apply, too. If you're considering monthly intervals, most of your events will occur at least once a month. The ones that don't will be easy to treat separately if they are common cases you want to factor out. Cheers, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

