Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Request: script to get SLT day of the week

Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
11-30-2007 18:35
Anybody got one?? Or even a pointer to some c/c++/c# code that has the formula to get from UTC seconds to the day of the week in a particular time zone?
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
11-30-2007 22:12
Basically, subtract 28800 (8hrs in seconds, offset from UTC to SLT, not accounting for DST) from the starting value, then divide by 86400 (seconds in a day, not accounting for any pesky leap-seconds between 1/1/1970 and now :p) and mod that with 7. If the result is 0, it's Thursday. If 1, Friday, and so on, through 6, which would obviously be Wednesday.

list days = [ "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" ];
integer day_of_week = ( UTC - 28800 ) / 86400 ) % 7;
llSay( 0, "Today is " + llList2String( days, day_of_week ) );
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
11-30-2007 23:26
wiki.secondlife.com/wiki/day_of_the_week
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-30-2007 23:36

fixed (spellign)
_____________________
|
| . "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...
| -
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
12-01-2007 11:19
/me looks embarrased..

For some reason, I had it stuck in my head that it had to figure leap years and such. None of that really matters when you're starting with seconds from a known date though, does it? :o

TY, all.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
been there, done that
12-01-2007 11:27
From: Sindy Tsure
For some reason, I had it stuck in my head that it had to figure leap years and such. None of that really matters when you're starting with seconds from a known date though, does it? :o

or even better a function that returns the day for you, leaving only the need to offset it for local time ;)

I've had days like this.... "Why can't I use llGetGMTclock() > previously_recorded_GMTcall ?" to which the answer was "because at midnight it goes to 0?"
_____________________
|
| . "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...
| -
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
12-01-2007 11:35
:)
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
12-01-2007 17:15
Take a look at a script I posted at the bottom of this entry in the wiki....

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetTimestamp

...it does what you need and more I think :)
_____________________
http://slurl.com/secondlife/Together