Jokey Domela
Registered User
Join date: 27 Jul 2005
Posts: 83
|
11-20-2005 17:00
Pretty sure this is correct. Feel free to test it out a bit... This will change a date mm/dd/yy to the day of the week. integer dayofweek; integer m=9; //Jokey Domela's Birthday! integer d=15; integer y=6; integer z; list days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
mathit() { if (m < 3) { z = y - 1; } else { z = y; } dayofweek = ( llFloor(23 * m/9) + d + 4 + y + llFloor(z/4) - llFloor(z/100) + llFloor(z/400))%7; if (m >= 3) { dayofweek = dayofweek - 2; } }
default { state_entry() { mathit(); string day = llList2String(days, dayofweek); llSay(0,(string)day); } }
|
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
|
Discussion Thread
11-20-2005 22:57
_____________________
i've got nothing. 
|
Bleu Drake
Registered User
Join date: 4 Mar 2006
Posts: 1
|
New day of week code
03-17-2006 20:41
Now that we can get the unix time of day, a much simpler formula for the day of week is available. (Note this code only calculates current day of week) list days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
// Returns day of week (PST), with 0 = Sunday integer day_of_week() { integer time = llGetUnixTime(); // Convert to server timezone, regardless of before or after midnight if(llGetWallclock() < llGetGMTclock()) { time -= (integer) (llGetGMTclock() - llGetWallclock()); } else { time -= 86400 + (integer) (llGetGMTclock() - llGetWallclock()); } return llFloor((time / 86400) - 3) % 7; }
default { state_entry() { string day = llList2String(days, day_of_week()); llSay(0,(string)day); } }
I release the above code to the public domain, feel free to license it however you wish. --Bleu Drake
|