llGetUnixTime()
, because of LSL integer type limitation, can return only 32 bits of epoch seconds. This means that around 19 January 2038, scripts that rely on counting the delta between two unix times will likely fail to function. Some workarounds are possible, but requires a lot of code to implement.
Short of introducing a new type,
integer64
, a (probably) much simpler workaround is to implement the following 2 functions:
list llGetUnixTime2()
returns a
list
whose first member is the higher-order 32 bits of a 64-bit unix epoch, while the second member is the lower-order 32-bits of the same unix epoch. The latter part is a bit tricky because it should be unsigned, so manual arithmetic might be a bit complex; hence, a second function:
integer llDiffUnixTime2(list unixtime_a, list unixtime_b)
given two list constructs as returned by
llGetUnixTime2()
, the function returns the number of seconds difference according to the rule of
a - b
.
Alternatively, encode the 64-bit unix time into
string
using Base64. And introduce the functions
string llGetUnixTimeB64()
and
integer llDiffUnixTimeB64(string a, string b)
. This might use less memory because
list
is a complex structure that requires more memory than a
string
.