http://www.perlmonks.org?node_id=556436


in reply to Re^2: Determining the dayname for the last day of any given month
in thread Determining the dayname for the last day of any given month

Not all days are 24*60*60 seconds long

Well the ones on the first of the month all are :)

But you're right, they aren't guaranteed to _always_ be. The easiest fix is probably to change the call to timelocal so it uses midday rather than midnight.

$m suffers from off-by-one errors

I don't think it does. The value you get from the user is in the range 1-12. We want the next month, but timelocal wants the number in the range 0-11. So we already have the correct number (except we need to do some adjustment if the month is 12). It might not be the clearest algorithm in the world, but it _is_ correct.

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

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

  • Comment on Re^3: Determining the dayname for the last day of any given month

Replies are listed 'Best First'.
Re^4: Determining the dayname for the last day of any given month
by ikegami (Patriarch) on Jun 20, 2006 at 16:06 UTC

    We want the next month

    Duh! Of course!