As I see it, you have a matrix by day and country, so that's a 365 x 195 matrix that's 1 bit wide. That database could be built every year by the programmer. All that tells you is that there is a Holiday to deal with. You don't care what country at this point.
This database has to be created yearly by the programmer with knowledge of leap year and the calendar.
You need a calendar database to build the event database.
So, you have a list of calendars and countries
e.g.
Calendar on the Y axis
countries on the X axis (just a list)
Gregorian US,country B, country B, country C
xxx, China
The you need a country/holiday database with an exception table.
December 25, (celebrated on that day), day of year (Note 1)
President's day (Celebrated on the Monday... ), day of year (Note 1)
In esscence the data-base get's built each time the year changes, knowing exceptions.
Note 1 says it's initially unknown, but when the database if built, xmas might fall on day 300 and that would be marked in the event to deal with data.
So, then it becomes
Is it Jan 1, 2008? Yes - build data-base once
What day (1-365) of the year is it?
Do I have an event? Yes, no
What country am I in?
Binary search the calendar data to find the holiday. At this point your searching for a number between (1-365).
Within each country you have a calendar and a holiday. That can be a list. You also have an exception code.
The 1-365 is an illustration, but it's probably better to use something like Excel's date system, so that dates can be added etc.
Suppose you had a Holiday that said once every 60 days. That's an exception and coded as such.
You really have a lot of smaller data bases that's used to build the event matrix.
The info that you did not state is how the notification might happen. X days before (easy). The Sunday before the event might be difficult.
The 1-365 is simplistic and probably should not be used. It really needs to be tied into the date function.
Examples that could probably be coded are things like the anniversary of Haley's comet. It goes in everybody's callendar. What about "Secretaries day" etc. So the database might have a level associated with it like.
National Holiday
Celestial observance
You can do Holiday and Holiday observed. You have Washington's and Lincoln's birthday, but you observe it on President's day.
Like levels of error messages like warning, severe, catastophic. A warning is "Mother's day", severe is "Washington's B-day", catastrophic is "President's day"
Think like:
What would I like this database to do if I had all the money and time in the world. Now think, "What do I need now"
It's not a simplistic problem and you know that.
You need to compile a list in the "language" of the calendar used with a "How calculated" mode by country.
The data-base will be built yearly into a 1 bit event matrix so your not searching every time.
You then know there is an event; then you know the country; Then binary search for the day since it's in order by day. You have to deal with a few days before and after too.
Once you have a list by country, holiday and "how calculated"; that should be able to be used to create an event database.
Not an easy task.
|