Difference between revisions of "Unix2StampLst"
Jump to navigation
Jump to search
Void Singer (talk | contribs) m (relocation from user page) |
m (<lsl> tag to <source>) |
||
Line 12: | Line 12: | ||
* MONO: 1024 bytes | * MONO: 1024 bytes | ||
<!-- Please replace with similarly licensed code only --> | <!-- Please replace with similarly licensed code only --> | ||
< | <source lang="lsl2">list uUnix2StampLst( integer vIntDat ){ | ||
if (vIntDat / 2145916800){ | if (vIntDat / 2145916800){ | ||
vIntDat = 2145916800 * (1 | vIntDat >> 31); | vIntDat = 2145916800 * (1 | vIntDat >> 31); | ||
Line 41: | Line 41: | ||
/*// 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 ] //*/ | ||
/*//-- --//*/</ | /*//-- --//*/</source> | ||
}} | }} | ||
Latest revision as of 14:46, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | User-Defined Functions | Void's User Page |
User-Defined Function: list uUnix2StampLst( integer vIntDat );
Returns a list that is a Unix time code converted to the format [Y, M, D, h, m, s]
- vIntDat: source Unix time code to convert
Code:
- LSO: 541 bytes
- MONO: 1024 bytes
list uUnix2StampLst( integer vIntDat ){
if (vIntDat / 2145916800){
vIntDat = 2145916800 * (1 | vIntDat >> 31);
}
integer vIntYrs = 1970 + ((((vIntDat %= 126230400) >> 31) + vIntDat / 126230400) << 2);
vIntDat -= 126230400 * (vIntDat >> 31);
integer vIntDys = vIntDat / 86400;
list vLstRtn = [vIntDat % 86400 / 3600, vIntDat % 3600 / 60, vIntDat % 60];
if (789 == vIntDys){
vIntYrs += 2;
vIntDat = 2;
vIntDys = 29;
}else{
vIntYrs += (vIntDys -= (vIntDys > 789)) / 365;
vIntDys %= 365;
vIntDys += vIntDat = 1;
integer vIntTmp;
while (vIntDys > (vIntTmp = (30 | (vIntDat & 1) ^ (vIntDat > 7)) - ((vIntDat == 2) << 1))){
++vIntDat;
vIntDys -= vIntTmp;
}
}
return [vIntYrs, vIntDat, vIntDys] + vLstRtn;
}
/*//-- 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
- Time codes before the year 1902 or past the end of 2037 are capped to the first second of 1902 and 2038 respectively