Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

date and time

Wotan Forsythe
Registered User
Join date: 12 Mar 2009
Posts: 3
05-22-2009 08:02
Im trying to create a script, which will say the current date and time - but not SL time, but our time here in Slovakia which is GMT+2hours! /or SL time + 9hours/

So I tried it so: integer total_secs = (integer)llGetGMTclock()+7200; /thats GMT + 7200seconds/

Is there any other way to get our time?

And the other problem is with current date. Is there any function to get the current date? /I mean the script will say : Today is 22th may 2009/. And if such function exists, the next problem is that in SL is other date as here in Europe with GMT+2 time, so how to obtain the current date here by us... /Example: SL time 22th May 2009 10:20 pm - but here in Europe is already 23th May 2009 7:20 am /


Thank you!
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
05-22-2009 08:20
The subject is well covered here: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetTimestamp
This forum has articles on the subject too.
Only a few weeks ago a speaking clock was up.
_____________________
From Studio Dora
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-22-2009 18:37
I wrote a function that gets the offset GMT timestamp with corrections for date... it'll be accurate for another 90years or so...

CODE

string uGetOffsetTimestamp( integer vIntOffset ){
string vStrOTS = llGetTimestamp();
//-- limit offset to +/-12hrs
vIntOffset = (vIntOffset + 12) % 24 - 12;

integer vIntTmp;
integer vIntCnt;
string vStrDIM ="__312831303130313130313031";

integer vIntYrs = (integer)llGetSubString( vStrOTS, vIntCnt, vIntCnt += 3 );
integer vIntMos = (integer)llGetSubString( vStrOTS, vIntCnt += 2, ++vIntCnt );
integer vIntDys = (integer)llGetSubString( vStrOTS, vIntCnt += 2, ++vIntCnt );
integer vIntHrs = (integer)llGetSubString( vStrOTS, vIntCnt += 2, ++vIntCnt );
vStrOTS = llDeleteSubString( vStrOTS, 0, vIntCnt );

vIntHrs = ((vIntTmp = vIntHrs + vIntOffset) + 24) % 24;
if (vIntTmp = (23 < vIntTmp) - (0 > vIntTmp)) {
vIntDys = vIntTmp += vIntDys;
if (vIntTmp = ((((integer)llGetSubString( vStrDIM, vIntMos << 1, (vIntMos << 1) + 1 )
+ ((vIntMos == 2) && !(vIntYrs & 3))) < vIntTmp) - (0 > vIntTmp))) {
vIntDys = (0 < vIntTmp) + (vIntTmp < 0)
* ((integer)llGetSubString( vStrDIM, vIntMos << 1, (vIntMos << 1) + 1 )
+ ((vIntMos += vIntTmp) == 2 && !(vIntYrs & 3)));
vIntMos = ((vIntTmp = vIntMos) + 11) % 12 + 1;
vIntYrs += ((12 < vIntTmp) - (1 > vIntTmp));
}
}

return (string)vIntYrs + "-" + uOTH( vIntMos ) + "-"
+ uOTH( vIntDys ) + "T" + uOTH( vIntHrs ) + vStrOTS;
}

string uOTH( integer vIntValue ){
return llGetSubString( "0"+ (string)vIntValue, -2, -1 );
}


I tuned it for speed, both micro and macro (hopefully I didn't miss anything), and yes I know I should have applied it in minutes (because of a few weird DST settings) it shouldn't he hard to add, I just did it this way to be tighter.

ETA:
I considered using the math variant for days of the month (30 | (m & 1) ^ (m > 7)) - (m == 2) - (y & 3 > 0), but I didn't test if it's be smaller (plus I'd need to figure where I could assign my variable in the second check)
_____________________
|
| . "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...
| -