Richard,<br><br>I have done something similar to this before. Date::Manip can use config files like Alan was showing, but your config for holidays can be more complex. For example, here is a section from a Date::Manip config file I made.<br>
<br>-----------DateManipConfig.txt<br><br>################################<br># CONFIG VARIABLES<br>################################<br># See Date::Manip man page for a description of all config variables.<br><br># EraseHolidays        =<br>
# PersonalCnf        = .DateManip.cnf<br># PersonalCnfPath    = .:~<br># Language        = English<br># DateFormat        = US<br># Must set time zone here for windows systems.<br>TZ            = CST<br># ConvTZ        =<br>
# Internal        = 0<br># FirstDay        = 1<br># WorkWeekBeg        = 1<br># WorkWeekEnd        = 5<br># WorkDay24Hr        = 0<br># WorkDayBeg        = 08:00<br># WorkDayEnd        = 17:00<br># TomorrowFirst        = 1<br>
# DeltaSigns        = 0<br># Jan1Week1        = 0<br># YYtoYYYY              = 89<br># UpdateCurrTZ        = 0<br># IntCharSet         = 0<br># ForceDate        =<br><br>################################<br># HOLIDAYS<br>################################<br>
*HOLIDAY<br><br># Make sure that the date part of every date can be followed by the year<br># and be correctly parsed by ParseDate.<br><br># The following holiday definitions are taken from pcal's config file.<br># Some are commented out if these tend to be ordinary business days.<br>
<br># For [system x] I only care about observed holidays. <br># If a holiday falls on a Sat or Sun it is all the same to [system x]<br><br>1*1:0:1:0:0:0*NWD               = New Year's Day (observed)<br>3rd Monday in Jan        = Martin Luther King Day<br>
third Monday in Feb             = Presidents' Day<br>last Monday in May              = Memorial Day<br>1*7:0:4:0:0:0*CWD               = Independence Day (observed)<br>1st Monday in Sep               = Labor Day<br>second Monday in Oct            = Columbus Day (observed)<br>
1*11:0:11:0:0:0*CWD             = Veterans' Day (observed)<br>1*11:4:4:0:0:0                  = Thanksgiving<br>1*11:4:5:0:0:0                  = Day After Thanksgiving<br>1*12:0:25:0:0:0*CWD             = Christmas Day (observed)<br>
<br># You can also use recurrences.<br><br>#1*0:0:0:0:0:0*EASTER        = Easter<br>#1*0:0:0:0:0:0*EASTER,PD5    = Good Friday<br><br><br># Other complex holidays (date + delta, date - delta)<br><br># first Monday in Nov + 1 day   = Election day<br>
# The Friday after Thanksgiving is an unnamed holiday some places<br># fourth Thu in Nov + 1 day     =<br><br># State specific holidays (set for Florida)<br><br># Alaska<br>#first Sat in March             = Iditarod starts<br>
<br># Only for MA, ME<br>#3rd Monday in Apr              = Patriots' Day<br><br># You can define specific holidays for specific years<br># 1/5/1999                      = A one-year-only holiday<br># 1st Monday in Sep 1998        = Another one.<br>
<br><br>-------------Code.pl<br>#Code.pl<br><br>use strict;<br>use Env;<br><br>use Data::Dump::Streamer;<br>use Date::Manip;<br>use Math::Round;<br>use DBI;<br><br>#datemanip config var and file<br>&Date_Init("GlobalCnf=DateManipConfig.txt");<br>
<br>-------snip----------<br>sub getDayType<br>  {<br>    my($d) = @_;<br>    # L - day is week day without a predceding or inpending day before a holiday<br>    # VF - last working day before holiday<br>    # PR - first working day after holiday<br>
    # F - hoilday/first day of a hoilday<br>    # RT - last day of holiday before next work day<br><br>    #print "\nDay:$d\n";<br><br>    #next day<br>    my $nd = DateCalc($d, "+ 1day");<br>    #day after next<br>
    my $dan = DateCalc($nd, "+ 1day");<br>    #previous day<br>    my $pd = DateCalc($d, "- 1day");<br>    #day before previous day<br>    my $dbpd = DateCalc($pd, "- 1day");<br><br>    # if day is work day, and previous and next day is not a holiday<br>
    if(Date_IsWorkDay($d) && Date_IsWorkDay($pd) && Date_IsWorkDay($nd))<br>      {<br>    return("L");<br>      }<br>    # if day is work day, and previous day is work day, and next day is holiday<br>
    if(Date_IsWorkDay($d) && Date_IsWorkDay($pd) && !Date_IsWorkDay($nd))<br>      {<br>    return("VF");<br>      }<br>    #if day is work day, and previous day was holiday, and next day is workday<br>
    if(Date_IsWorkDay($d) && !Date_IsWorkDay($pd) && Date_IsWorkDay($nd))<br>      {<br>    return("PR");<br>      }<br>    #if day is hoilday, and next day is holiday<br>    if(!Date_IsWorkDay($d) && !Date_IsWorkDay($nd))<br>
      {<br>    return("F");<br>      }<br>    #if day is workday, and next day and previous day are holidays<br>    if(Date_IsWorkDay($d) && !Date_IsWorkDay($nd) && !Date_IsWorkDay($pd))<br>      {<br>
    return("F");<br>      }<br>    #if day is hoiliday and next day is workday and day after next is holiday<br>    if(!Date_IsWorkDay($d) && Date_IsWorkDay($nd) && !Date_IsWorkDay($dan))<br>      {<br>
    return("F")<br>      }<br>    #if day is holiday, and next day is work day<br>    if(!Date_IsWorkDay($d) && Date_IsWorkDay($nd))<br>       {<br>     return("RT");<br>       }<br>    return();<br>
  }<br><br>-------Snip---------<br><br>Hope this helps,<br><br>Eric<br><br><div class="gmail_quote">On Fri, Jul 13, 2012 at 8:25 AM,  <span dir="ltr"><<a href="mailto:richard@rushlogistics.com" target="_blank">richard@rushlogistics.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks very much for all the replys. Jay I think you are correct. What I was looking to do is to write a script that alerts me of upcoming holidays. From what I coming to understand the existing perl modules allow me to "do things" with dates. But as I gather I have to supply the dates. What I though might exist was a perl module that actually calculates holidays such that you ask it what day is thanksgiving and it returns the date. It looks like Joel's website does this but I was hoping to avoid depending on an outside source. Also Alan you code is great but I want something that actually crunches the numbers and calculates the dates.<br>

<br>
I was on my way to doing this when I started to wonder if someone had already done it and put it in a perl module. I think I will resume the task of writing something on from scratch.<br>
<br>
Thanks again for all of the insightful and supportive replys.<br>
<br>
Richard<br>
<br>
<br>
El Jul 12, 2012, a las 7:53 PM, Jay Strauss <<a href="mailto:me@heyjay.com">me@heyjay.com</a>> escribió:<br>
<div class="HOEnZb"><div class="h5"><br>
> Richard, I get the feeling you are looking for a module with built in<br>
> knowledge of the dates of various holidays.  I'm not sure if such a<br>
> thing exists. (admittedly I haven't searched)<br>
><br>
> The docs for DateTime::Event::Holiday::US; seem like it just a module<br>
> for naming dates and proving a wrapper to the underlying  modules<br>
><br>
> I think you need a module that let's you supply a calendar (dates with<br>
> names) and then gives you functions for navigating that calendar<br>
><br>
><br>
> Thanks<br>
> Jay<br>
><br>
> Sent from my iPhone<br>
><br>
> On Jul 12, 2012, at 12:34 PM, Richard Reina <<a href="mailto:richard@rushlogistics.com">richard@rushlogistics.com</a>> wrote:<br>
><br>
>><br>
>> Hi Mike,<br>
>><br>
>> Thank you very much for the suggestion.  With some difficulty I was able to get the module installed. However, I am unclear on how it works.  The example given in the docs:<br>
>><br>
>> use DateTime::Event::Holiday::US;<br>
>><br>
>> my $thanksgiving = DateTime::Event::Holiday::US::holiday( 'Thanksgiving' );<br>
>><br>
>><br>
>> gives me a hash reference which when I try to dereference with:<br>
>><br>
>> my %hash =  %$thanksgiving;<br>
>><br>
>> foreach my $k (keys %hash) {<br>
>>       print "$k: $hash{$k}\n";<br>
>>   }<br>
>><br>
>><br>
>> gives me:<br>
>><br>
>> as_ical: ARRAY(0x1e63190)<br>
>> set: Too complex<br>
>><br>
>> I was hoping it might give me the date for Thanksgiving.<br>
>><br>
>> If any one can give me an idea as to what I am doing wrong in trying to use this module I would really appreciate it.<br>
>><br>
>> Thanks,<br>
>><br>
>> Richard<br>
>><br>
>><br>
>><br>
>>><br>
>>> Mike Fragassi <<a href="mailto:mikefrag@gmail.com">mikefrag@gmail.com</a>> wrote:<br>
>><br>
>>> Try DateTime::Event::Holiday::US.<br>
>><br>
>>> On Jul 3, 2012 3:46 PM, <<a href="mailto:richard@rushlogistics.com">richard@rushlogistics.com</a>> wrote:<br>
>>><br>
>>> I am lost trying to write a simple script that tells<br>
>>> me how many days until the next approaching holiday.<br>
>>> has anyone ever done anything similar or know of anything<br>
>>> helpful. I've looked at Date::Manip but that still<br>
>>> leaves me with the cumbersome task of finding out<br>
>>> which holiday is the next one from a given date.<br>
>>><br>
>>> Any help would be appreciated as not solving it will<br>
>>> keep me preoccupied all through the holiday.<br>
>>><br>
>>> Thanks<br>
>>><br>
>>> Richard<br>
>>> _______________________________________________<br>
>>> Chicago-talk mailing list<br>
>>> <a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
>>> <a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br>
>><br>
>><br>
>> --<br>
>> Richard Reina<br>
>> Rush Logistics, Inc.<br>
>> Watch our 3 minute movie:<br>
>> <a href="http://www.rushlogistics.com/movie" target="_blank">http://www.rushlogistics.com/movie</a><br>
>><br>
>> _______________________________________________<br>
>> Chicago-talk mailing list<br>
>> <a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
>> <a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br>
> _______________________________________________<br>
> Chicago-talk mailing list<br>
> <a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
> <a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br>
_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a></div></div></blockquote></div><br><br clear="all"><br>-- <br>Eric Ellington<br><a href="mailto:e.ellington@gmail.com">e.ellington@gmail.com</a><br>