Difference between revisions of "LlGetDate"

From Second Life Wiki
Jump to navigation Jump to search
(fun with operators)
m
Line 44: Line 44:
     }
     }
}</lsl>
}</lsl>
<lsl>// Function to calculate whether a current year is a leap year
integer is_leap_year( integer year )
{   
    if( year % 4 )        return FALSE;  // Not a leap year under any circumstances   
    if( year <= 1582 )    return TRUE;    // In the Julian calender before 24 February 1582, every fourth year was a leap year
    if( !( year % 400 ))  return TRUE;    // A leap century is a leap year if divisible by 400
    if( !( year % 100 ))  return FALSE;  // Any other century is not a leap year 
    return TRUE;                          // It is divisible by 4 and not a century and not Julian, therefore it is a leap year
}
</lsl>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llGetTimestamp]]|Same format but with the time.}}
|also_functions={{LSL DefineRow||[[llGetTimestamp]]|Same format but with the time.}}

Revision as of 07:06, 4 July 2008

Summary

Function: string llGetDate( );

Returns a string that is the current date in the UTC time zone in the format "YYYY-MM-DD".

If you wish to know the time as well use: llGetTimestamp which uses the format "YYYY-MM-DDThh:mm:ss.ff..fZ"

Examples

<lsl>// Birthday surprise default {

   state_entry()
   {   
       llSetTimerEvent(0.1);
   }
   timer()
   {
       if(llGetDate() == "2009-02-15")
           llSetText("HAPPY BIRTHDAY!", <0,1,0>, 1.0);
       else
           llSetText("A surprise is coming...", <0,1,0>, 1.0);
        
       llSetTimerEvent(3600.0);  // check every hour. 
   }

}</lsl> <lsl>// Function to calculate the numeric day of year integer dayOfYear(integer year, integer month, integer day) {

   return day + (month - 1) * 30 + (((month > 8) + month) / 2)
- ((1 + (((!(year % 4)) ^ (!(year % 100)) ^ (!(year % 400)))

See Also

Functions

•  llGetTimestamp Same format but with the time.

Articles

•  ISO 8601

Deep Notes

Search JIRA for related Issues

Signature

function string llGetDate();