hacker has asked for the wisdom of the Perl Monks concerning the following question:
A confusing node title, but please read on...
I'm trying to come up with a simple little script that can spit out a week's worth of days (5 work days), regardless of what day I execute the script on.
For example, if I run the script on Saturday (i.e. the 6th day of the week), I want it to output the previous Monday through Friday.
If I execute the script on Wednesday, it should output the Monday of that week, Tuesday, Wednesday (the day I run it), tomorrow (Thursday) and the day after (Friday).
This is more of a math question than Perl I suppose. Is there an easy way to find the closest week to the day I execute the script? It will either be the previous week, or the current week, depending on which day I run the script. Something in Date::Calc? Some other module?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calculating the "nearest" week
by eibwen (Friar) on Apr 25, 2005 at 01:48 UTC | |
|
Re: Calculating the "nearest" week
by bobf (Monsignor) on Apr 25, 2005 at 04:21 UTC | |
|
Re: Calculating the "nearest" week
by tlm (Prior) on Apr 25, 2005 at 01:56 UTC | |
|
Re: Calculating the "nearest" week
by TedPride (Priest) on Apr 25, 2005 at 07:18 UTC | |
|
Re: Calculating the "nearest" week
by adrianh (Chancellor) on Apr 25, 2005 at 17:02 UTC | |
|
Re: Calculating the "nearest" week
by NateTut (Deacon) on Apr 25, 2005 at 15:01 UTC |