Unix2StampLst
Jump to navigation
Jump to search
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