in reply to Date munging suddenly broken
28, 9, 2000 28, 9, 2000 28, 9, 2000 28, 9, 2000 28, 9, 2000 27, 9, 2000 21, 9, 2000 21, 9, 2000
That isn't right at all... How about this:
sub next_friday { my $now = shift || time(); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$rest) = localtime($now); my $then = (($wday-5) * 60 * 60 * 24); ($sec,$min,$hour,$mday,$mon,$year,$rest) = localtime($now - $then); $mon += 1; $year += 1900; return "$year.$mon.$mday"; }
That is evil as heck but it works. If you want this friday to return next friday, you can ++$wday before the $then calc.
Notice I fancied it up enough that you can send it arbritary times or it will default to time(). Notice I made it a sub. Notice what I did to the logic.
Now, forget all that except as a basic lesson in how things work and use Date::Manip =)
--
$you = new YOU;
honk() if $you->love(perl)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Date munging suddenly broken
by btrott (Parson) on Oct 05, 2000 at 02:44 UTC |