develooper Front page | perl.beginners | Postings from April 2002

Re: Backing up two days from localtime

Thread Previous | Thread Next
Tara Calishain
April 26, 2002 05:32
Re: Backing up two days from localtime
Message ID:
At 02:05 AM 4/26/2002, Jeff 'japhy' Pinyan wrote:
> >I need to back up two days from localtime and I can't figure out how to do
> >it. Currently I'm doing this just so I can work out the rest of the program:
> >
> >($day, $month, $year) = (localtime) [3,4,5]; #getting your local time
>The generic (read: potentially unsafe) way is to fix the problem right
>   ($day, $month, $year) = (localtime(time - 86400*2))[3,4,5];
>The only place to worry about this is during the switch to/from Daylight
>Savings Time, at 2:00 am, twice a year.

Thanks Jeff and Timothy. (And thanks to Jonathan too, but I'm on Windows.)

Actually, are there any books/docs that talk specifically about dealing 
with time?
I'm anticipating coming across this same problem with user input dates, and
I don't expect the seconds trick will work for that one.

For example, say a user specified $day-$month-$year and ten days, and I
wanted to generate a date string for every day going back ten days.

I begin to see the appeal of Julian days. At least with those all you have
to do is subtract one.

Apparently I've learned some kind of critical mass of perl because I'm writing
scripts all over the place. Well, the Google API also had something to do 
with it,
I suspect.

Thank you again for your help!


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About