Difference between revisions of "Stamp2WeekdayStr"

From Second Life Wiki
Jump to navigation Jump to search
m (added byte costs)
m (<lsl> tag to <source>)
 
Line 14: Line 14:
* MONO: 1024 bytes
* MONO: 1024 bytes
<!-- Please replace with similarly licensed code only -->
<!-- Please replace with similarly licensed code only -->
<lsl>string uStamp2WeekdayStr( integer vIntYear, integer vIntMonth, integer vIntDay ){
<source lang="lsl2">string uStamp2WeekdayStr( integer vIntYear, integer vIntMonth, integer vIntDay ){
return llList2String ( ["Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"],
return llList2String ( ["Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"],
                       (vIntYear + (vIntYear >> 2) - ((vIntMonth < 3) & !(vIntYear & 3)) + vIntDay
                       (vIntYear + (vIntYear >> 2) - ((vIntMonth < 3) & !(vIntYear & 3)) + vIntDay
Line 23: Line 23:
/*//  2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]  //*/
/*//  2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]  //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                --//*/</lsl>
/*//--                                                                --//*/</source>
}}
}}



Latest revision as of 14:35, 22 January 2015

Summary

User-Defined Function: string uStamp2WeekdayStr( integer vIntYear, integer vIntMonth, integer vIntDay );

Returns a string that is the day of the week for the given date.

  • vIntYear: source year
  • vIntMonth: source month
  • vIntDay: source day


Code:

  • LSO: 237 bytes
  • MONO: 1024 bytes
string uStamp2WeekdayStr( integer vIntYear, integer vIntMonth, integer vIntDay ){
return llList2String ( ["Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"],
                       (vIntYear + (vIntYear >> 2) - ((vIntMonth < 3) & !(vIntYear & 3)) + vIntDay
                       + (integer)llGetSubString( "_033614625035", vIntMonth, vIntMonth )) % 7 );
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/

Caveats

  • Accurate from 1901 to 2099