Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Re: Re: Date

by dws (Chancellor)
on Mar 12, 2001 at 04:42 UTC ( [id://63702]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Date
in thread How to find yesterdays date (was: Date)

By my calculation (which may well be wrong), subtracting 24 to determine yesterday's date is wrong during one one-hour period per year, and adding 24 hours to determine tomorrow's date is wrong during a second one-hour period, each period corresponding to one of the adjustments.

If I'm wrong, please set me straight.

Updated:

I wasn't 100% sure I was right, so I did a bit of research and an experiment with Time::Local. At least in most of the U.S. (there are exceptions, dammit), we do the daylight savings switch by either repeating 1-2am on the first Sunday of April, by by skipping from 1:59:59 to 3:00:00am on the last Sunday of October. In either case, it's save to subtract 24 hours from the current time for the purposes of determining the previous date.

Nope, I was right the first time.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Date
by Anonymous Monk on Mar 12, 2001 at 05:31 UTC
    You are wrong. During a year there will be a 23 hour day and a 25 hour day. For the hour before the 23 hour day, adding 24 hours to get tomorrow's date won't work, it will get the day after tomorrow's date. For the first hour of the 25 hour day, adding 24 hours will get the same day's date. For the hour after the 23 hour day, subtracting 24 hours will get the date two days ago. For the last hour of the 25 hour day, subtracting 24 hours will get the same day's date.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found