Difference between revisions of "LlGetWallclock"
Jump to navigation
Jump to search
m |
m (<lsl> tag to <source> - last of llGetFoo yay) |
||
(20 intermediate revisions by 11 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LSL_Function | ||
|func_id=81|func_sleep=0.0|func_energy=10.0 | |||
|func=llGetWallclock|return_type=float | |||
|func_footnote=For GMT use [[llGetGMTclock]] | |||
|func_desc | |||
|return_text=that is the time in seconds since midnight Pacific time (PST/PDT), truncated to whole seconds. That is the same as the time of day in SLT expressed as seconds. | |||
|spec | |||
|caveats | |||
|constants | |||
|examples=<source lang="lsl2">// Real World Sun | |||
integer Flag; | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
Flag = -1; | |||
llSetTimerEvent(0.1); | |||
} | |||
timer() | |||
{ | |||
float time = llGetWallclock(); | |||
if (Flag == -1) | |||
{ | |||
llSetTimerEvent(60.0); | |||
} | |||
if (time < 21600) | |||
{ | |||
if (Flag) | |||
{ | |||
llSetText("The Sun is coming! :)", <1,1,0>, 1.0); | |||
Flag = 0; | |||
} | |||
} | |||
else if (time < 64800) | |||
{ | |||
if (Flag != 1) | |||
{ | |||
llSetText("Sun has risen. :(", <1,0,0>, 1.0); | |||
Flag = 1; | |||
} | |||
} | |||
else if (Flag != 2) | |||
{ | |||
llSetText("Goodbye Sun. :(", <1,0,0>, 1.0); | |||
Flag = 2; | |||
} | |||
} | |||
}</source> | |||
<source lang="lsl2">// Convert to human-readable HH:MM:SS format | |||
string ConvertWallclockToTime() | |||
{ | |||
integer now = (integer)llGetWallclock(); | |||
integer seconds = now % 60; | |||
integer minutes = (now / 60) % 60; | |||
integer hours = now / 3600; | |||
return llGetSubString("0" + (string)hours, -2, -1) + ":" | |||
+ llGetSubString("0" + (string)minutes, -2, -1) + ":" | |||
+ llGetSubString("0" + (string)seconds, -2, -1); | |||
} | |||
default | |||
{ | |||
touch_start(integer total_number) | |||
{ | |||
llSay(0, ConvertWallclockToTime()); | |||
} | |||
} | |||
</source> | |||
|helpers | |||
|also_functions= | |||
{{LSL DefineRow||[[llGetGMTclock]]|Seconds since midnight GMT}} | |||
|also_events | |||
|also_tests | |||
|also_articles | |||
|notes=To determine if the current time returned by this function is PST or PDT, you can look at the difference between llGetGMTclock() and llGetWallclock(). The difference will be either 8 hours or -16 hours for PST, and 7 hours or -17 hours for PDT, that is 28800 or -57600, or 25200 or -61200 seconds. | |||
|permission | |||
|negative_index | |||
|sort=GetWallclock | |||
|cat1=Time | |||
|cat2 | |||
|cat3 | |||
|cat4 | |||
}} |
Revision as of 03:09, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: float llGetWallclock( );81 | Function ID |
0.0 | Forced Delay |
10.0 | Energy |
Returns a float that is the time in seconds since midnight Pacific time (PST/PDT), truncated to whole seconds. That is the same as the time of day in SLT expressed as seconds.
For GMT use llGetGMTclock
Caveats
Examples
// Real World Sun
integer Flag;
default
{
state_entry()
{
Flag = -1;
llSetTimerEvent(0.1);
}
timer()
{
float time = llGetWallclock();
if (Flag == -1)
{
llSetTimerEvent(60.0);
}
if (time < 21600)
{
if (Flag)
{
llSetText("The Sun is coming! :)", <1,1,0>, 1.0);
Flag = 0;
}
}
else if (time < 64800)
{
if (Flag != 1)
{
llSetText("Sun has risen. :(", <1,0,0>, 1.0);
Flag = 1;
}
}
else if (Flag != 2)
{
llSetText("Goodbye Sun. :(", <1,0,0>, 1.0);
Flag = 2;
}
}
}
// Convert to human-readable HH:MM:SS format
string ConvertWallclockToTime()
{
integer now = (integer)llGetWallclock();
integer seconds = now % 60;
integer minutes = (now / 60) % 60;
integer hours = now / 3600;
return llGetSubString("0" + (string)hours, -2, -1) + ":"
+ llGetSubString("0" + (string)minutes, -2, -1) + ":"
+ llGetSubString("0" + (string)seconds, -2, -1);
}
default
{
touch_start(integer total_number)
{
llSay(0, ConvertWallclockToTime());
}
}
Notes
To determine if the current time returned by this function is PST or PDT, you can look at the difference between llGetGMTclock() and llGetWallclock(). The difference will be either 8 hours or -16 hours for PST, and 7 hours or -17 hours for PDT, that is 28800 or -57600, or 25200 or -61200 seconds.
See Also
Functions
• | llGetGMTclock | – | Seconds since midnight GMT |