Don't click here unless you want to be banned.

LSL Wiki : LibraryGetDayOfWeek

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
Method to get the day of the week from a unix timestamp - llGetUnixTime. The timestamp returns the number of seconds elapsed beginning Thursday, January 1, 1970 UTC. This script first converts the seconds to hours, then adds the GMT offset (if desired), then converts the hours to days, and finally grabs the day of the week from a list.

// 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)); 
    } 
}

And a function version:

string getDay(integer offset) { 
    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); 
}

default { 
    touch_start(integer total_number) {
        integer offset = -4; // offset from UTC
        llSay(0, "Today is " + getDay(offset) + "."); 
    } 
}

Alternate method at: Day of the Week by RichardSolvang

ScriptLibrary
There is no comment on this page. [Display comments/form]