Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by davorg (Chancellor)
on Jun 20, 2006 at 15:52 UTC ( #556436=note: print w/ replies, xml ) Need Help??


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 (Pope) on Jun 20, 2006 at 16:06 UTC

    We want the next month

    Duh! Of course!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://556436]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2015-07-28 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls