Difference between revisions of "LlGetDate"
Jump to navigation
Jump to search
m (Added type cast) |
Void Singer (talk | contribs) m (+ helper functions) |
||
Line 54: | Line 54: | ||
return TRUE; // It is divisible by 4 and not a century and not Julian, therefore it is a leap year | return TRUE; // It is divisible by 4 and not a century and not Julian, therefore it is a leap year | ||
}</lsl> | }</lsl> | ||
|helpers | |helpers= | ||
=== Helper Functions === | |||
* [[User:Void_Singer/Functions#List_format_to_Unix_time_code.|Timestamp: list format to Unix timestamp]] - ex: [2009, 2, 13, 3, 31, 30] to 1234567890 | |||
** compatible with [[llParseString2List]]( [[llGetDate]](), ["-"], [] ) (reports as first second of given day) | |||
* [[User:Void_Singer/Functions#Weekday_from_.28_Y.2C_M.2C_D_.29_format|Timestamp: Weekday from (Y, M, D)]] - ex: "Friday" from (Y, M, D) | |||
|also_functions={{LSL DefineRow||[[llGetTimestamp]]|Same format but with the time.}} | |also_functions={{LSL DefineRow||[[llGetTimestamp]]|Same format but with the time.}} | ||
|also_events | |also_events |
Revision as of 08:58, 16 January 2010
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 integer dayOfYear(integer year, integer month, integer day) {
return day + (month - 1) * 30 + (((month > 8) + month) / 2)- ((1 + (((!(year % 4)) ^ (!(year % 100)) ^ (!(year % 400)))
Useful Snippets
Helper Functions
- Timestamp: list format to Unix timestamp - ex: [2009, 2, 13, 3, 31, 30] to 1234567890
- compatible with llParseString2List( llGetDate(), ["-"], [] ) (reports as first second of given day)
- Timestamp: Weekday from (Y, M, D) - ex: "Friday" from (Y, M, D)