Clock: Difference between revisions
Jump to navigation
Jump to search
Omei Qunhua (talk | contribs) mNo edit summary |
Omei Qunhua (talk | contribs) |
||
| Line 14: | Line 14: | ||
timer() | timer() | ||
{ | { | ||
float fSecs = llGetWallclock(); // Get SL time in seconds (will be either PST or PDT) | float fSecs = llGetWallclock(); // Get SL time in seconds (will be either PST or PDT) | ||
string PST_PDT = " PST"; // Assume Pacific Standard Time | string PST_PDT = " PST"; // Assume Pacific Standard Time | ||
if ( (llGetGMTclock() - fSecs) < 27000.0) // If difference between SLT and UTC is less then 7.5 hours, then SLT is currently PDT | if ( (llGetGMTclock() - fSecs) < 27000.0) // If difference between SLT and UTC is less then 7.5 hours, then SLT is currently PDT | ||
PST_PDT = " PDT"; // Pacific Daylight Time | PST_PDT = " PDT"; // Pacific Daylight Time | ||
Mins = (integer) fSecs / 60; | integer Mins = (integer) fSecs / 60; | ||
Hours = Mins / 60; | integer Hours = Mins / 60; | ||
Mins = Mins % 60; | Mins = Mins % 60; | ||
AMPM = " AM"; | string AMPM = " AM"; | ||
if (Hours > 11) // Convert to 12-hour format with PM indication | if (Hours > 11) // Convert to 12-hour format with PM indication | ||
{ | { | ||
Revision as of 15:26, 17 December 2013
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Show the current SL time (PST/PDT)
<lsl> // Simple SLT 12-hour clock with AM/PM and PDT/PST indicators. Uses llGetWallClock() and llGetGMTclock() // Omei Qunhua
default {
state_entry()
{
llSetTimerEvent(1);
}
timer()
{
float fSecs = llGetWallclock(); // Get SL time in seconds (will be either PST or PDT)
string PST_PDT = " PST"; // Assume Pacific Standard Time
if ( (llGetGMTclock() - fSecs) < 27000.0) // If difference between SLT and UTC is less then 7.5 hours, then SLT is currently PDT
PST_PDT = " PDT"; // Pacific Daylight Time
integer Mins = (integer) fSecs / 60;
integer Hours = Mins / 60;
Mins = Mins % 60;
string AMPM = " AM";
if (Hours > 11) // Convert to 12-hour format with PM indication
{
AMPM = " PM";
Hours -= 12;
}
if (Hours == 0)
Hours = 12;
llSetText( (string) Hours + ":" + llGetSubString("0" + (string) Mins, -2, -1) + AMPM + PST_PDT, <1,1,1> ,1);
}
} </lsl>