Clock

From Second Life Wiki
Revision as of 14:01, 12 February 2007 by Beverly Larkin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Say the current time (PST)
<lsl>


integer H; //Hours
integer M; //Minutes
string AP; //AM or PM

default
{
    state_entry()
    {
        integer T = (integer)llGetWallclock(); // Get time PST
        if (T > 43200) //If it's after noon
        {
            T = T - 43200; //Subtract 12 hours
            AP = "PM";  //set to PM
            H = T / 3600; //get hours
            M = (T - (H * 3600)) / 60; //get minutes
            if(H == 0) //if the hour is 0
            {
                H = 12; // make the hour 12
            }
        }
        else
        {
            AP = "AM";
            H = T / 3600; //get the hour
            M = (T - (H * 3600)) / 60; //get minutes
            if(H == 0) //if the hour is 0
            {
                H = 12; // make the hour 12
            }
        }
        llOwnerSay((string)H + ":" + (string)M + AP);
    }
}