motomuse has asked for the wisdom of the Perl Monks concerning the following question:
I have a subroutine whose original intent was to mung the date so as to name a file based on whatever the date is of the Friday of the given week. So that, for example, if it's Wednesday 10/4/2000, the file gets gets titled 10_6_2000.html (with the idea that it's appended to after that).
It worked fine up to some unspecified time ago (I only found out it was broken when one of my users reported a different problem entirely). Now it's telling me that Friday is 9/28/2000. Here's the code in question:
$now = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$rest) = localtime($now); if ($wday !=4) { $dow = $wday; if ($dow < 4) { $dow += 7; } $then = (($dow - 4) * 60 * 60 * 24); } ($sec,$min,$hour,$mday,$mon,$year,$rest) = localtime($now - $then); $mon=$mon+1; $year=$year+1900;
Why's it not working? Should it have ever worked??
Thanks for your attention.
- Muse
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jcwren) Re: Date munging suddenly broken
by jcwren (Prior) on Oct 05, 2000 at 00:58 UTC | |
by motomuse (Sexton) on Oct 05, 2000 at 01:59 UTC | |
by jcwren (Prior) on Oct 05, 2000 at 02:11 UTC | |
by merlyn (Sage) on Oct 05, 2000 at 10:39 UTC | |
|
RE: Date munging suddenly broken
by extremely (Priest) on Oct 05, 2000 at 02:00 UTC | |
by btrott (Parson) on Oct 05, 2000 at 02:44 UTC |