Difference between revisions of "Millisec"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "{{LSL Header|User-Defined Functions|Nexii's User Page}} <!-- please do not remove added links --> <div style="floa…")
 
m (<lsl> tag to <source>)
 
Line 8: Line 8:


<!-- Please replace with similarly licensed code only -->
<!-- Please replace with similarly licensed code only -->
<lsl>
<source lang="lsl2">
integer Millisec(string Stamp) {
integer Millisec(string Stamp) {
     return (integer)llGetSubString(Stamp, 8, 9) * 86400000 + // Days
     return (integer)llGetSubString(Stamp, 8, 9) * 86400000 + // Days
Line 17: Line 17:
}
}
/*// Released to Public Domain without limitation. Created by Nexii Malthus. //*/
/*// Released to Public Domain without limitation. Created by Nexii Malthus. //*/
</lsl>
</source>
}}
}}



Latest revision as of 15:27, 22 January 2015

Summary

User-Defined Function: integer Millisec( string Stamp );

Returns an integer of milliseconds that is within a months range, starting from -617316353 to 2147483547.

  • Stamp: a string formatted as it comes from llGetTimestamp
integer Millisec(string Stamp) {
    return (integer)llGetSubString(Stamp, 8, 9) * 86400000 + // Days
        (integer)llGetSubString(Stamp, 11, 12) * 3600000 + // Hours
        (integer)llGetSubString(Stamp, 14, 15) * 60000 + // Minutes
        llRound(((float)llGetSubString(Stamp, 17, -2) * 1000.0)) // Seconds.Milliseconds
        - 617316353; // Offset to fit between [-617316353,2147483547]
}
/*// Released to Public Domain without limitation. Created by Nexii Malthus. //*/

Caveats

  • Accurate to within a month