Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Useful Subroutines Unix_time_code_to_list_format  

Unix_time_code_to_list_format

Unix_time_code_to_list_format

Category: Useful Subroutines
By : Void Singer
Created: 2010-02-01 Edited: 2010-02-01
Worlds: Second Life

the Zip file

Download all files for Unix_time_code_to_list_format
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Unix_time_code_to_list_format_1.lsl
1 Time codes before the year 1902 or past the end of 2037
2 are capped to the first second of 1902 and 2038 respectively
3
4 Output is [Y, M, D, h, m, s] list format.
5
6 This version could be improved.
7
8 list uUnix2StampLst( integer vIntDat ){
9 if(vIntDat / 2145916800){
10 vIntDat = 2145916800 * (1 | vIntDat >> 31);
11 }
12 integer vIntYrs = 1970 + ((((vIntDat %= 126230400) >> 31) + vIntDat / 126230400) << 2);
13 vIntDat -= 126230400 * (vIntDat >> 31);
14 integer vIntDys = vIntDat / 86400;
15 list vLstRtn = [vIntDat % 86400 / 3600, vIntDat % 3600 / 60, vIntDat % 60];
16
17 if(789 == vIntDys){
18 vIntYrs += 2;
19 vIntDat = 2;
20 vIntDys = 29;
21 }else{
22 vIntYrs += (vIntDys -= (vIntDys > 789)) / 365;
23 vIntDys %= 365;
24 vIntDys += vIntDat = 1;
25 integer vIntTmp;
26 while(vIntDys > (vIntTmp = (30 | (vIntDat & 1) ^ (vIntDat > 7)) - ((vIntDat == 2) << 1))){
27 ++vIntDat;
28 vIntDys -= vIntTmp;
29 }
30 }
31 return [vIntYrs, vIntDat, vIntDys] + vLstRtn;
32 }
33 /*//-- Anti-License Text --//*/
34 /*// Contributed Freely to the Public Domain without limitation. //*/
35 /*// 2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/
36 /*// Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ] //*/
37 /*//--

Back to the Best Free Tools in Second Life and OpenSim.