Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
12-21-2009 19:06
Trying to adjust for timezones so we get something to work at midnight on new year. How bad is this? It should work once the new year is detected but the hour is dubious. It gets turned off once do_Stuff is run once. timer(){ TimeStamp = llParseString2List(llGetTimestamp(),["-",":"],["T"]); integer Hour = llList2Integer(TimeStamp,4) + fixtime; //fixtime is timezone adjustment + or - Hours, eg +10 or -5 year = llList2Integer(TimeStamp,0); if(Hour == 0){ if (year == NewYear ){do_Stuff();} }
else return; }
Thanks
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-21-2009 21:36
there's a get time at offset function someone wrote on the forums, but I'm not finding it.....
but if you just want to to fire at midnight new years per time zone, then just get the unix time and calculate from that. much easier to offset from.
_____________________
| | . "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... | - 
|
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
|
12-21-2009 23:35
This should work, a snippet from one of my clocks integer offset=-8; //timezone offset from GMT eg SLT is -8 hours
integer hours; integer minutes; integer secs=(integer)llGetGMTclock(); //seconds from midnight
offset=offset*60*60; //offset in seconds if(offset<0) offset=offset+86400; //add 24 hours if a negative offset
secs=secs+offset; secs=secs%86400; hours=secs/3600; minutes=(secs%3600)/60;
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-22-2009 01:38
lacks date detection.
if (llGetUnixTime() > 1262303999 - offset) //-- it's a new year.
ETA: corrected signing
_____________________
| | . "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... | - 
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
12-22-2009 15:11
I spent hours going over the time related functions and believed I had the best way. That's why I was a house painter.
Thanks team.
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
|
12-22-2009 18:56
Here's what I have from my PIM Hud, I found the code browsing forum posts on the subject. I think this is the only way to make sure you have the right offset regardless of when daylight savings goes into effect:
tzAdj = (integer)(llGetGMTclock() - llGetWallclock())/3600; if (tzAdj < 0) tzAdj += 24; lNow = Unix2DateTime(llGetUnixTime()-(tzAdj*3600));
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-22-2009 19:43
From: Soen Eber Here's what I have from my PIM Hud, I found the code browsing forum posts on the subject. I think this is the only way to make sure you have the right offset regardless of when daylight savings goes into effect:
tzAdj = (integer)(llGetGMTclock() - llGetWallclock())/3600; if (tzAdj < 0) tzAdj += 24; lNow = Unix2DateTime(llGetUnixTime()-(tzAdj*3600)); well at least for US-DST
_____________________
| | . "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... | - 
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
12-23-2009 02:49
Yeess.. Seems I baffle myself with complexity. Keep it simple. Thanks Void.
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
12-23-2009 05:46
Thanks for the help I think I got it finished but there may (will) be something that could be done better Now that I've posted it here I can see a couple of things that I couldn't 5 minutes ago. Oh well. tried to keep that Timer area simple. Much simpler than before. How's it look so far? //Kornscope Komachi's Exciting New Year Thing. Dec2009 //
//Set the do_Stuff function to go off with a Unix Time Code. //Get it @ http://www.4webhelp.net/us/timestamp.php integer GoOffAt = 1262303999;//This IS New Year minus one second
//Offset for Time Zones, Zero is GMT Set via dialog float offset = 0.0;
key DetKey; integer channel = 0;
list MainMenu = ["TimeZone+","TimeZone-","Add30Mins","Stop","Dance","Magic","Start","Done"]; list TimeZonePlus = ["12","11","10","9","8","7","6","5","4","3","2","1"]; list TimeZoneMinus = ["-12","-11","-10","-9","-8","-7","-6","-5","-4","-3","-2","-1"];
string MainMsg = "Set the Time Zone, stop and start the Timer \n and add 30 minutes if needed";
do_Stuff(){ //Turn off timer llSetTimerEvent(0); //Send message to other prims llMessageLinked(LINK_ALL_OTHERS,0,"GO_OFF_NOW",DetKey); //Shout our message to everyone around llShout(PUBLIC_CHANNEL,"Happy New Year 2010 from " + llKey2Name(llGetOwner())+"\n I hope this New 2010 Year is wonderful for you all"); }
do_Dialog(list Menu,string Dmessage){ llDialog(DetKey,Dmessage + "\n Time Zone Offset is set at " +(string) offset + " Hours" , Menu, channel); }
default { state_entry(){ }
touch_start(integer total_number){ DetKey = llDetectedKey(0); channel=(integer) llFrand (1000000)+1; llListen(channel, "",DetKey, ""); do_Dialog(MainMenu,MainMsg); } listen(integer channel, string name, key id, string msg){ if(DetKey == llGetOwner()){ if(llListFindList(MainMenu,[msg]) != -1){ if (msg=="Stop"){ llSetTimerEvent(0); // llMessageLinked(LINK_ALL_OTHERS,760,msg,""); do_Dialog(MainMenu,MainMsg + "\n Timer STOPPED"); } else if (msg=="Start"){ llSetTimerEvent(1); // llMessageLinked(LINK_ALL_OTHERS,761,msg,""); do_Dialog(MainMenu,MainMsg + "\n Timer RUNNING"); } else if (msg=="Dance"){ llMessageLinked(LINK_ALL_OTHERS,762,msg,""); do_Dialog(MainMenu,MainMsg); } else if (msg=="Magic"){ llMessageLinked(LINK_ALL_OTHERS,763,msg,""); do_Dialog(MainMenu,MainMsg); } else if (msg=="Add30Mins"){ offset += 0.5; llOwnerSay("TimeZone is set at " + (string)offset + " Hours"); do_Dialog(MainMenu,MainMsg); } else if (msg=="TimeZone+"){ do_Dialog(TimeZonePlus,"Set a post GMT TimeZone"); } else if (msg=="TimeZone-"){ do_Dialog(TimeZoneMinus,"Set a Pre GMT TimeZone"); } } else if(llListFindList(TimeZonePlus + TimeZoneMinus,[msg]) != -1){ offset = (float)msg; llOwnerSay("TimeZone is set at " + msg + " Hours"); do_Dialog(MainMenu,MainMsg); } } else return; } timer(){ float off_set = offset*3600; if (llGetUnixTime()+ off_set > GoOffAt ){do_Stuff();} else return; }
}//END
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|