in reply to Date::Manip and Date::Calc

How about a solution that doesn't use any non-standard modules?

#!/usr/bin/perl -w use strict; use Time::Local; use POSIX 'strftime'; my @now = localtime; $now[4]++; if ($now[4] == 12) { $now[4] = 0; $now[5]++; } $now[3] = 1; my @then = localtime(timelocal(0, 0, 12, @now[3 .. 5]) - 86_400); print strftime '%Y-%m-%d', @then;
--
<http://www.dave.org.uk>

"The first rule of Perl club is you don't talk about Perl club."

Replies are listed 'Best First'.
Re: Re: Date::Manip and Date::Calc
by blakem (Monsignor) on Oct 22, 2001 at 21:50 UTC
    Is Time::Local a standard module? I had to install it manually for 5.005_03, though it seems to have come standard with my 5.6.0 installation.

    I once asked a similiar question, but since you used both Time::Local and POSIX, I'll ask it again. Is there a particular reason you chose Time::Local::timelocal() over POSIX::mktime()?

    -Blake

      Time::Local has been a part of standard Perl for at least six years. If you had to install it manually for 5.005_03, then I think you had a broken installation.

      The reason for using Time::Local::timelocal is that it's a function that I know and use. I didn't know that POSIX::mktime existed until you mentioned it the other day. In this case, POSIX::mktime might make more sense, as it would mean loading one less module.

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you don't talk about Perl club."