Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

calculate date in diferent time zones

Fanny Foxtrot
Registered User
Join date: 31 Oct 2008
Posts: 2
11-04-2008 15:40
hi guys,

i was wondering if its possible to calculate a date on GMT and at the same time PST.

For instance, at a specific moment it could be 1AM at GMT so the date would be Nov 5th and at the same time 5PM at PST Nov 4th.

is there a way to now this from a lsl function?

thanx in advanced :)
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
11-04-2008 16:55
For THOSE two particular timezones you can use the functions llGetGMTclock() and llGetWallclock() and infer whether the date is different between the two locations based on the results (i.e. if the time is later in the Pacific region, it must be one day behind the GMT date). I suggest that because it will automatically factor in daylight savings.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-04-2008 16:57
just get GMT, add/subtract your offset, and check to see if the calcualtion lies outside the range of 00:00-23:59... if it does, correct and add or subtract a day as appropriate.

conceptually:
x= GMT+ offset
if x >= 24hours get date and add 1
if x < 0hours get date and subtract 1

using llGetGMTclock and llGetDate

EDIT: good call hewee, if wall > GMT, get date -=1 day for PST
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Fanny Foxtrot
Registered User
Join date: 31 Oct 2008
Posts: 2
11-05-2008 16:29
thank you both, I got the picture :)

I'm just starting sls but i'll try to do it :)


EDIT:

btw, wall can never be > GMT because wall is always GMT-8(not counting DST). wall is actually = PST.

or am I missing something?
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
11-06-2008 02:48
From: Fanny Foxtrot


btw, wall can never be > GMT because wall is always GMT-8(not counting DST). wall is actually = PST.

or am I missing something?
I think you are, I'm afraid. Wall is > than GMT from 16:00 until 23:59 PST every day, during which time it's 00:00 to 07:59 the following day here in London. Which is what you wanted to check for.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-06-2008 03:55
Actually to be accurate for the whole year, you have to build a list of how many days in each month.

Nov 1st, 1AM GMT == Oct 31st 5PM PST

And to be completely accurate you need to account for leap years.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-06-2008 07:45
both wallclock and gmt are seconds from midnight, so yeah it can be greater because it's still running seconds from the previous day. Jesse makes an excellent point too, you'll need at least the last day for each previous month, as well as a special tick for both the year changeover(assuming you want the WHOLE date), and leap years.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -