Steven J. Weinberger wrote:
> After writing this module, my plan is to write the necessary event 
> modules to calculate the Jewish Holidays. That's an obvious 
> "DateTime::Event::JewishHolidays" or something like that. When I 
> reach a point where the information I help calculate is only useful to 
> Observant Jews, does the work leave the realm of DateTime and enter 
> a different namespace, like "Religion::Jewish"? At what point would my 
> modules cease being relevant to this group? My initial feelings are 
> that after DateTime::Event::JewishHolidays, I start adding to 
> Religion::Jewish, and posting the announcements here.


G'day Steve,

I've written what I currently call DateTime::Event::Christian and it's
data module DateTime::Event::Christian::Catholic, but the Christian.pm
has nothing to do with a Christian (or any religious) calendar. I'm
wondering if I shouldn't release it as DateTime::Event::Calendar. Then
anyone can write data modules for it: Civil, Religious or anything else.

Basically the data file is a complex hash whose elements look something
like the following (the actual file is at work so I cant get to it for
another hour or so):

        {
                name => 'Easter Sunday',
                callback => \&get_easter,
                protocol => 'overwrite',
                data => {
                        color => 'Red',
                        season => 'Easter',
                }
        },

        {
                name => 'Good Friday',
                relative => 'Easter Sunday',
                offset => -2,
                protocol => 'overwrite',
                data => {
                        color => 'Red',
                        season => 'Holy Week',
                }
        }

        {
                name => 'Christmas',
                set ={
                        month => 12,
                        day => 25,
                }
                offset => -2,
                protocol => 'overwrite',
                data => {
                        color => 'Red',
                        season => 'Holy Week',
                }
        }

The 'name' attribute is obvious. Next we have one of:
- a callback (which gets passed the year IIRC) which should return a
day-of-year.
- a relative/offset pair. This is also fairly self explainatory. Good
Friday is related to 'Easter Sunday' with an offset of -2. Basically
it's 2 days before Easter.
- a set of elements such as month/day for events like Christmas. This
could be any elements that can be passed to a 'new' constructor for a
particular 
calendar.

After that there's a protocol. This is set to a constant:
'overwrite': If there's already something there, overwrite it
'forward': If there's already something there, move ourself forward to
the next available day*
'backward': as above, but backward*
'delete': If there's already an event on that day then delete this
event.
* Both forward and backward can have an integer at the end such as
'forward7' which will move it forward by 7 days until it finds a
same-day-of-the-week that it can insert itself at.

The 'data' attribute can contain any data you'd like. For the Catholic
calendar it contains the colors and the seasons of the event.

Anyway, I'm not sure if your calendar would use these logics, but if
it's similar this will get me off my arse and get me back to working on
the module. If there's further protocols you need, lets write them.

Cheers!
Rick



Reply via email to