Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Day of the week

Lavanya Hartnell
Registered User
Join date: 9 Dec 2005
Posts: 55
08-05-2006 17:15
Does anyone have an LSL function or such to determine day of week? For today will do, but also for a given Unix time (llGetUnixTime) would also be cool. Thanks.
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
08-05-2006 19:23
CODE
// Gives day of the week
// DoteDote Edison

list weekdays = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"];
integer offset = -4; // offset from UTC

default {
state_entry() {
//
}
touch_start(integer total_number) {
integer hours = llGetUnixTime()/3600;
integer days = (hours + offset)/24;
integer day_of_week = days%7;
llSay(0, "Today is " + llList2String(weekdays, day_of_week));
}
}

Here's a function for ya:
CODE

integer offset = -4; // offset from UTC

string getDay() {
list weekdays = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"];
integer hours = llGetUnixTime()/3600;
integer days = (hours + offset)/24;
integer day_of_week = days%7;
return llList2String(weekdays, day_of_week);
}
Lavanya Hartnell
Registered User
Join date: 9 Dec 2005
Posts: 55
08-06-2006 13:31
Thanks a bunch for the quick and clear response. I'll have to give this a try.

It's a shame LL doesn't provide more date & time functions. I can see people have found interesting ways to avoid dealing with them, as a result. Oh, well. At least there are helpful people like you. Thanks, again.

- Lavanya