in reply to Module Code Review

Your leap year calculation is incorrect. 2004 is a leap year, 2000 is a leap year, 1904 is a leap year, but 1900 is NOT. The rule is:
if (!($y % 4) and ($y % 100 or !($y % 400))) { ... }
Other than that, here's a much simpler method for finding out yesterday:
use Time::Local; my $noon = timelocal(0,0,12, (localtime)[3,4,5]); my ($d,$m,$y) = (localtime($noon - 86400))[3,4,5];

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
(tye)Re: Module Code Review
by tye (Sage) on Sep 15, 2001 at 09:58 UTC

    You don't even need Time::Local,

    my $yesterday= do { my($y,$m,$d)= (localtime( time-60*60*(12+(localtime)[2]) ))[5,4,3]; sprintf "%04d-%02d-%02d", 1900+$y, 1+$m, $d; };
    or, just for fun:
    my $yesterday= join"-",mapcar{sprintf "%0".shift()."d",pop()+pop()} [4,2,2],[(localtime( time-60*60*(12+(localtime)[2]) ))[5,4,3]],[1900,1,0];

            - tye (but my friends call me "Tye")