Difference between revisions of "LlGetDate"

From Second Life Wiki
Jump to navigation Jump to search
(fun with operators)
Line 8: Line 8:
|caveats
|caveats
|constants
|constants
|examples=<lsl>
|examples=<lsl>// Birthday surprise
// Birthday surprise
default
default
{
{
Line 26: Line 25:
         llSetTimerEvent(3600.0);  // check every hour.  
         llSetTimerEvent(3600.0);  // check every hour.  
     }
     }
}
}</lsl>
</lsl>
<lsl>// Function to calculate the numeric day of year
<lsl>
integer dayOfYear(integer year, integer month, integer day)
// Function to calculate the numeric day of year (probably won't work for years before 12C AD)
integer getDayOfYear(integer year, integer month, integer day)
{
{
     return  
     return day + (month - 1) * 30 + (((month > 8) + month) / 2)
          day
         - ((1 + (((!(year % 4)) ^ (!(year % 100)) ^ (!(year % 400))) | (year <= 1582))) && (month > 2));
        + (month - 1) * 30
         - (2 -
            ((year % 4 == 0) && ((year % 100 != 0) || (year <= 1582) || (year % 400) == 0))
          ) * (month > 2)
        + (month / 2) * (month <= 8) + (4 + (month - 7) / 2) * (month > 8);  
}
}


Line 51: Line 43:
         llSay(0, "The current day of the year is " + dayOfYear(year, month, day));
         llSay(0, "The current day of the year is " + dayOfYear(year, month, day));
     }
     }
}
}</lsl>
</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.}}
Line 59: Line 50:
|also_articles={{LSL DefineRow||[http://www.cl.cam.ac.uk/~mgk25/iso-time.html ISO 8601]|}}
|also_articles={{LSL DefineRow||[http://www.cl.cam.ac.uk/~mgk25/iso-time.html ISO 8601]|}}
|notes
|notes
|permission
|negative_index
|cat1=Time
|cat1=Time
|cat2
|cat2

Revision as of 09:02, 2 July 2008

Summary

Function: string llGetDate( );
0.0 Forced Delay
10.0 Energy

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

Signature

function string llGetDate();