Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Clock Get_Day_of_Week  

Get_Day_of_Week

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.

Category: Clock
By : DoteDote Edison
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Get_Day_of_Week
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Get_Day_of_Week_1.lsl
Get file # 2. Get_Day_of_Week_2.lsl
1 // Gives day of the week
2 // DoteDote Edison
3
4 list weekdays = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"];
5 integer offset = -4; // offset from UTC
6
7 default {
8 state_entry() {
9 //
10 }
11 touch_start(integer total_number) {
12 integer hours = llGetUnixTime()/3600;
13 integer days = (hours + offset)/24;
14 integer day_of_week = days%7;
15 llSay(0, "Today is " + llList2String(weekdays, day_of_week));
16 }
17 }

Get_Day_of_Week

And a function version:

Category: Clock
By : DoteDote Edison
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 string getDay(integer offset) {
2 list weekdays = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"];
3 integer hours = llGetUnixTime()/3600;
4 integer days = (hours + offset)/24;
5 integer day_of_week = days%7;
6 return llList2String(weekdays, day_of_week);
7 }
8
9 default {
10 touch_start(integer total_number) {
11 integer offset = -4; // offset from UTC
12 llSay(0, "Today is " + getDay(offset) + ".");
13 }
14 }

Back to the Best Free Tools in Second Life and OpenSim.