[EMAIL PROTECTED] wrote: >> This occurs on the 23th hour in the fall and the 0th hour in the spring. > This program shows a brute force way >> to find these that might convince you [1]. > > > Slick! I'm convinced. Hmm, so if you need it to be ever accurate (and want > to stay w/ localtime() you need to track changes in the DST field, > something like: > my ($isdst) = ( localtime() ) [8]; > > my ($mday, $mon, $year, $prev_isdst) = (localtime(time - 60 * 60 * 24) )[ > 3,4,5, 8]; > printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, > $isdst == $prev_isdst ? $mday > : $isdst > $prev_isdst ? (localtime($t - 60 * 60 * 23) )[ 3] > : (localtime($t - 60 * 60 * 25) )[ 3] > ); >
If he's only interested in the date and not the time, I would think just using localtime and changing the hour field to noon and using Time::Local::timelocal to reverse back to epoch time would ensure that your next localtime call would produce the correct date no matter what the time is. use Time::Local; my @t = localtime; # convert epoch time for today to fields $t[2] = 12; # change hour to noonish my $time = timelocal (@t); # convert back to epoch time my @d = localtime $time; # @d now has the correct date for yesterday # which you could also use with POSIX::strftime # to format as you like _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs