Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: storing and 'understanding' complex calendar events (including recurring events)

by socketdave (Curate)
on May 26, 2006 at 20:12 UTC ( [id://551932]=note: print w/replies, xml ) Need Help??


in reply to storing and 'understanding' complex calendar events (including recurring events)

Check out Date::Manip.

If you give it a specification for a recurring event it can give you a list of future matching dates. The format isn't as simple as your example but it can do some cool stuff. This may at least be a good place to start.
  • Comment on Re: storing and 'understanding' complex calendar events (including recurring events)

Replies are listed 'Best First'.
Re^2: storing and 'understanding' complex calendar events (including recurring events)
by Tobin Cataldo (Monk) on May 26, 2006 at 20:31 UTC
    Date:Manip is the best....

    Check especially Date:Manip:ParseRecur()
    Dates are stored in an array
    my $start = '01/01/2006'; my $end = '12/31/2010'; my @fourth_tuesdays = ParseRecur("0:1*4:2:0:0:0", $start,$start,$end,) +; my @last_workday_of_every_month = ParseRecur("0:1*0:-1:0:0:0*PWD", $st +art,$start,$end,);


    I haven't found anything nearly as good...
    Tobin
      so this would mean that pre-calculating dates would be my only real option, i guess? Assuming that i have a couple of hundred events, there would be no other way to simply call something like
      @events = showEvents( $date );
      ?
        The events would still need to be tied to a date though.
        I am not sure how to model this data exactly but I would approach it as event 1->N date property. Then you would calculate your date ranges for each date property once and connect events to dates. I am assuming some sort of relational db. Date:Manip is slower than some of the other options. But it is super powerful.
        Well, you either need to store the definition for the event or the complete list of events. Storing the definition and expanding it to the full list when needed keeps the database of events simple and easy to work on. On the other hand, it's probably going to be pretty slow when you need to go through the list and calculate if each event matches a given day. The opposite is true of storing an expanded list of dates for each event. It's a trade like everything else.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://551932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-20 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found