in reply to A Better Way To Get Days Since Monday of Last Week

my $today = (localtime)[6]; my $target_day = 1; # monday $target_day -= 7; # last week printf "%d days since target day\n", $today - $target_day;

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: A Better Way To Get Days Since Monday of Last Week
by Tommy (Chaplain) on Jun 07, 2005 at 15:54 UTC
    Purrrrrrrrfect. Why do these 'simple logic' questions evade me all the time?! What you show is _exactly_ what i was looking for —a mathematical solution rather than a hard coded if/then sequence (really that's what i was doing) covering all the bases. Imagine doing that for something with hundreds or thousands of possible states! Sheesh! I feel so stupid.
    --
    Tommy Butler, a.k.a. Tommy