LPM: Re: Test / question on date stuff

Tom Scanlan tom at squarefish.com
Wed Feb 9 14:16:47 CST 2000


Dates are hard.  They always blow my mind unless I'm doing something in the
middle of a month, but the edges.... ouch.

I've got two ideas; one easy, and one more difficult, but fun (:
1) use Date::Calc from CPAN.  It handles dates lke you wouldn't believe.
You can look up holidays, calculate the number of days (or businesss days...
or hours... or months... etc.) between two dates.  It's cool.

2) make a circular list of 12 almost circular lists.  Each of the 12 lists
contain a month.  The last day of each month links you to the first day in
the next month, or in the case of December, link it back to January first.
Then pick your date and cycle through these lists for x days and read out
your new day.  I think the perl cookbook has an example of circular lists.


0  1 ...  11
1  1       1
2  .         .
3  .         .
.   .         31
.  29
.
31

-Tom Scanlan


----- Original Message -----
From: "Carl Rose" <lothos_25 at yahoo.com>
To: <lexington-pm-list at pm.org>
Sent: Wednesday, February 09, 2000 10:33 AM
Subject: LPM: Test / question on date stuff


> OK,
>    I just subscribed and test to see if this gets out
> where I want it.  Second:  I have a question
> concerning the incrementation of the day of the month.
>  I am a newbie of sorts so I ask your forgiveness in
> advance for my lack of knowledge.  But I am trying to
> learn and that is more than most are willing to do.
> To wit -- I have a script that needs to rotate date
> functions in 28 day intervals- I have the following
> code
>
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
> = localtime(time);
>     $mon += 1;
>     $year = $year +1900;
>
>    print "$mon/$mday/$year \n";
>
> It of course returns the date just like I want it
> (02/09/2000).  So what code do I issue to get 28 days
> from now added onto the day and get the correct
> rollaround. (ie when you add 28 above you get Feb 37th
> -ugg instead of the early part of March).  Any help
> would be appreciated and go toward good karma.
>
> Regards,
> -C
>
>
> =====
> "The only thing that saves us from the bureaucracy is its inefficiency."
> -Eugene McCarthy
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com




More information about the Lexington-pm mailing list