## LSL Wiki : LibraryDayofWeek

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
```//By Richard Solvang
//Sunday, July 31, 2005
//Based on function referenced from http://mathforum.org/library/drmath/view/55837.html

string GetDay(float year, float month, float date)
{
if(month < 3) {month += 12; --year;}        // These lines mathematicly translate
integer N = (integer)date;                  // Date, Month and year
N += (integer)(2.0 * month);                // into a number which represents
N += llFloor(3.0 * (month + 1.0) / 5.0);    // a given day of the week.
N += (integer)year;                         // 0 = Saturday     1 = Sunday
N += llFloor(year / 4.0);                   // 2 = Monday       3 = Tuesday
N -= llFloor(year / 100.0);                 // 4 = Wednesday    5 = Thursday
N += llFloor(year / 400.0);                 // 6 = Friday
N += 2;                                     //
N = N % 7;                                  // The rest of the function
// translates the number
// into the name of the day.

string day;
if(N == 0) day = "Saturday";
else if(N == 1) day = "Sunday";
else if(N == 2) day = "Monday";
else if(N == 3) day = "Tuesday";
else if(N == 4) day = "Wednesday";
else if(N == 5) day = "Thursday";
else if(N == 6) day = "Friday";
return day;
}```

If this interests you take a look at http://mathforum.org/library/drmath/view/55837.html and http://mathforum.org/dr.math/faq/faq.calendar.html - RichardSolvang

ScriptLibrary