Re: Time Zones and Users
by count0 (Friar) on Jan 10, 2002 at 22:32 UTC
|
I've never done this, so I can't walk you through it... But here's a ray of light:
The Time-modules package from CPAN will definitely help (and specifically Time::Timezone). | [reply] |
|
|
The problem with Time::Timezone is that it relies on the
$ENV{TZ} variable, which (as far as I can tell) relies on the /usr/share/zoneinfo
files.
-- I write the code while the master is away!
| [reply] |
|
|
From Time::Zone (which is the same as Time::Timezone iirc):
$TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : ''
unless $TZ;
Where $TZ is taken as the first argument (to the functions needing a base timezone). =)
So, in other words, you can pass it a value and it does not rely on there being a TZ environment variable.
| [reply] [d/l] |
|
|
Re: Time Zones and Users
by TStanley (Canon) on Jan 10, 2002 at 22:32 UTC
|
A quick search on CPAN turned up several choices such as Time::Timezone and Time::Zone. For a complete list of what I found, you can go here.
TStanley
--------
"Suppose you were an idiot... And suppose you were a member of Congress... But I repeat myself." -- Mark Twain
| [reply] |
Re: Time Zones and Users
by thor (Priest) on Jan 11, 2002 at 10:23 UTC
|
At my company, we run several instances of a scheduler program all around the world. All any of them care about is 'what is my local time?'. The user makes the adjustment. For instance, I'm in Minneapolis, MN and the scheduler that I'm looking at is in Sydney, Australia. I have to keep track of the time difference (right now, it is 17 hours I think). I think that this is the way to go. If you will be doing anything local to the server, you should be doing everything on the servers time.
Of course, if it really matters to you, you could do some version of an rsh to the remote server to execute a timelocal((localtime())[0,1,2,3,4,5]) and store it in a variable. Do the same thing on the client side, and find the difference between the two. Pass the difference into gmtime to get the difference in hours and minutes (not all timezones are an integer number of hours apart, so the minutes are necessary).
thor | [reply] [d/l] [select] |
Re: Time Zones and Users
by belg4mit (Prior) on Jan 11, 2002 at 10:56 UTC
|
perl -e 'print scalar localtime; $ENV{TZ}="PST"; print scalar localtim
+e;'
Assuming you aren't in PST. and then you might just local
the TZ within a block when you do the calculations etc.
PD> Corollary, let the OS and perl internal magic do as much work for you as it can.
--
perl -pe "s/\b;([st])/'\1/mg"
| [reply] [d/l] |
|
|
Hmmm. That's a good method, but it doesn't seem to work for Windows servers. Yeah, a crime against nature, but it's a requirement, and it's making this simple issue into a total beast.
Thor, your idea of just setting a +/- X hours is nice, but doesn't take into account Daylight Savings Time. A lot of the world and some parts of America (Arizona, east Indiana) don't deal with it at all. If you do DST in your area, Check the current time on this site. If you set your options when our clocks were forward, it'll be off by one hour. That's fine for a realtime site like this, but no good for a scheduling app.
-- I write the code while the master is away!
| [reply] |
|
|
| [reply] |