Difference between revisions of "LlGetDate"
Jump to navigation
Jump to search
Line 29: | Line 29: | ||
</lsl> | </lsl> | ||
<lsl> | <lsl> | ||
// Function to calculate the numeric day of year | // Function to calculate the numeric day of year (probably won't work for years before 12C AD) | ||
integer | integer getDayOfYear(integer year, integer month, integer day) | ||
{ | { | ||
return | return | ||
day | |||
+ (month - 1) * 30 - ( | + (month - 1) * 30 | ||
- (2 - | |||
(year <= 1582) | |||
|| ((year % 4 == 0) && ((year % 100 != 0) || (year % 100) == 0)) | |||
) * (month > 2) | |||
+ (month / 2) * (month <= 8) + (4 + (month - 7) / 2) * (month > 8); | |||
+ (month / 2) * (month <= 8) + (4 + (month - 7) / 2) * (month > 8); | |||
} | } | ||
Revision as of 07:17, 2 July 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string llGetDate( );204 | Function ID |
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"
Caveats
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 (probably won't work for years before 12C AD) integer getDayOfYear(integer year, integer month, integer day) {
return day + (month - 1) * 30 - (2 -(year <= 1582)