Right now I'm running it as a CGI, but I'll probably modify it to run nightly via a cron job, and just rename an appropriate image from, say, groundhogsDay.gif to currentHoliday.gif to save processor time. But, anyway, on to the problem.
to make things easy, I'm using Date::Manip (which, of course, isn't horribly fast, hence the desire to probably run it as a stand alone, cron-activated script in the end, rather than a CGI each time a user does something).
So, I've got a little script like so (for testing finding the right holiday).
use Date::Manip;
&Date_Init("EraseHolidays=0", "PersonalCnf=dateManip.conf");
$eventsToday = &Events_List("today");
@eventList = @{$eventsToday}; #list in format (date, (list of event names));
@eventName = @{$eventList[1]}; #second item of list is the list of event names, ('event 1', 'event 2');
$todayIs = $eventName[0];
print "Today is $todayIs\n";
with my dateManip.conf file like so:
*Events
Jan 1 = newYears 3rd Mon in Jan ; 2nd Mon in Jan = MLKDay Feb 14 ; Feb 7 = valentinesDay 2nd Sun in May ; May 1 = monthersDay last Mon in May; 2nd Mon in May = memorialDay Jul 4 ; last mon in June = independenceDay 1st mon in sep ; last mon in august = laborDay 2nd Mon in Oct ; 1st Mon in Oct = ColumbusDay 4th Thu in Nov ; 2nd Thu in Nov = Thanksgiving Dec 25 ; Dec 11 = Christmas
The idea is, I don't want to necessarily "celebrate" each holiday for the same length of time. Now, my two questions.
First, as you can see, I listed events in the format event date ; date I want the image to first appear. It appears from the date::manip docs that I should be able to instead do something like event date ; -n days, for example:
3rd Mon in Feb; -2day = WashingtonB-day
to get a washington's birthday image from the saturday preceding the 3rd monday to the 3rd monday in feb. but, that seems to give strange results - I always get the next holiday defined that way following the current date, even if it's listed as -1 day and we're months before it.
Am I misunderstanding how Date::Manip treats its events configuration, or is this a bug? Any better way to work around it than to make rough judgements of what should be "OK" like I did?
The second question: How would one calculate election day here in the us?
$election = ParseDate("1st Tue after 1st Mon in Nov");
just doesn't quite work. It seems a little obscure. It'd be pretty simple in a script to find the first tuesday and see if it's > the 1st. But, I can't really do that in the config file, since it is just read in and the dates parsed when the script is run.
Any ideas there?
TIA
Chad A Gard http://www.percussionadvocates.com/chad
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>