Difference between revisions of "User:Void Singer/Functions"
Void Singer (talk | contribs) m (added update notice) |
Void Singer (talk | contribs) m (updated) |
||
Line 2: | Line 2: | ||
{{void-box | {{void-box | ||
|title=[[User:Void_Singer|Return to Void Singers user page]] | |title=[[User:Void_Singer|Return to Void Singers user page]] | ||
}} | }} | ||
Line 304: | Line 207: | ||
* These Functions are related to [[llGetUnixTime]] and [[llGetTimestamp]]. | * These Functions are related to [[llGetUnixTime]] and [[llGetTimestamp]]. | ||
=== Weekday from Unix timestamp === | === Weekday from Unix timestamp === | ||
* Updated 29 May, 2010 | |||
<lsl>/*//-- Note: | <lsl>/*//-- Note: | ||
Accurate from 1901 to 2099 (no limiting code) | Accurate from 1901 to 2099 (no limiting code) | ||
Line 310: | Line 214: | ||
string uUnix2WeekdayStr( integer vIntDat ){ | string uUnix2WeekdayStr( integer vIntDat ){ | ||
return llList2String( ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"], | return llList2String( ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"], | ||
vIntDate % 604800 / 86400 | vIntDate % 604800 / 86400 + (vIntDate >> 31) ); | ||
} | } | ||
/*//-- Anti-License Text --//*/ | /*//-- Anti-License Text --//*/ |
Revision as of 03:54, 29 May 2010
List: Find Last Index
- This function is a companion to llListFindList.
- SPECIAL NOTE: this is only designed to work on string data that will NOT contain the "•" character(alt+7)... please use a different character to suit your needs.
Get Last Index of List Test in List Source
<lsl>integer uGetLstIdxRev( list vLstSrc, list vLstTst ){
integer vIdxFnd = (vLstSrc != []) + ([] != vLstTst) + ([] != llParseString2List( llList2String( llParseStringKeepNulls( llDumpList2String( vLstSrc, "•" ), (list)llDumpList2String( vLstTst, "•" ), [] ), -1 ), (list)"•", [] ));return (vIdxFnd
List: Multi-Find Index (First or Last)
- These functions are companions to llListFindList.
Get First Index in List Source of any element in List Test
<lsl>integer uMatchLstIdxFwd( list vLstSrc, list vLstTst ){
return ((llParseString2List( llList2String( llParseStringKeepNulls( llDumpList2String( vLstSrc, ";" ), vLstTst, [] ), 0 ), (list)";", [] ) != []) + 1) % ((vLstSrc != []) + 1) - 1;
} /*//-- 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 ] //*/ /*//-- --//*/</lsl>
Get Last Index in List Source of any element in List Test
<lsl>integer uMatchLstIdxRev( list vLstSrc, list vLstTst ){
return (vLstSrc != []) - (llParseString2List( llList2String( llParseString2List( llDumpList2String( vLstSrc, ";" ), vLstTst, [] ), -1 ), (list)";", [] ) != []) - 1;
} /*//-- 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 ] //*/ /*//-- --//*/</lsl>
Timestamp: Converters
- These Functions are companions to llGetUnixTime and llGetTimestamp.
Unix time code to list format.
UPDATED: Jan. 27, 2010. <lsl> /*//-- Notes:
Time codes before the year 1902 or past the end of 2037 are capped to the first second of 1902 and 2038 respectively Output is [Y, M, D, h, m, s] list format. This version could be improved.
//*/
list uUnix2StampLst( integer vIntDat ){ if (vIntDat / 2145916800){
vIntDat = 2145916800 * (1Timestamp: Get Weekday from timestamp
- These Functions are related to llGetUnixTime and llGetTimestamp.
Weekday from Unix timestamp
- Updated 29 May, 2010
<lsl>/*//-- Note:
Accurate from 1901 to 2099 (no limiting code)
//*/
string uUnix2WeekdayStr( integer vIntDat ){
return llList2String( ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"], vIntDate % 604800 / 86400 + (vIntDate >> 31) );
} /*//-- 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 ] //*/ /*//-- --//*/</lsl>
Weekday from ( Y, M, D ) format
<lsl>/*//-- Note:
Accurate from 1901 to 2099 (no limiting code)
This version could be improved.
//*/
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 ] //*/ /*//-- --//*/</lsl>