Page 1 of 1

EffectiveWay To Store Date Definitions

Posted: Mon Sep 01, 2008 3:01 am
by lightnb
I need a table to store the 'definition' of dates (not an actual date).

For example, "First and third Friday of every month", "The 25th of December", "Every Monday and Wednesday", and "The last Sunday of February".

They need to be stored in such a way that a script can easily pull out the rules and see if today matches any of them.

Any Ideas?

Re: EffectiveWay To Store Date Definitions

Posted: Mon Sep 01, 2008 5:23 am
by onion2k
You need four parts for each rule - the day it falls on, the frequency at which it occurs, and the start and end points. Each rule should only deal with 1 period at a time. Eliminate any rules like "First and third Friday of every month" ... that should be two different rules, one for the 1st Friday and one for the 3rd Friday. Based on that it should be fairly straightforward to define a set of criteria for every eventuality and design a schema to hold all the necessary rules. It'll be a heck of a lot of work mind you. Good luck.

I would also suggest you read the RFC for the iCalendar format... http://www.ietf.org/rfc/rfc2445.txt It's pretty complicated stuff but it might help.