LlGetDate/ja
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
LSL ポータル | 関数 | イベント | 型 | 演算子 | 定数 | 実行制御 | スクリプトライブラリ | カテゴリ別スクリプトライブラリ | チュートリアル |
要約
関数: llGetDate( );UTC タイムゾーンでの現在の日付を "YYYY-MM-DD" 形式で返します。
時間を "YYYY-MM-DDThh:mm:ss.ff..fZ" の形式で知りたい場合は llGetTimestamp を使います。
サンプル
// 誕生日サプライズ
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); // 毎時間チェックを行う
}
}
// 通日を計算する関数
integer dayOfYear(integer year, integer month, integer day)
{
return day + (month - 1) * 30 + (((month > 8) + month) / 2)
- ((1 + (((!(year % 4)) ^ (!(year % 100)) ^ (!(year % 400))) | (year <= 1582))) && (month > 2));
}
default
{
touch_end(integer count)
{
list dateComponents = llParseString2List(llGetDate(), ["-"], []);
integer year = (integer) llList2String(dateComponents, 0);
integer month = (integer) llList2String(dateComponents, 1);
integer day = (integer) llList2String(dateComponents, 2);
llSay(0, "The current day of the year is " + (string) dayOfYear(year, month, day));
}
}
// うるう年かどうか計算する関数
integer is_leap_year( integer year )
{
if( year % 4 ) return FALSE; // 何があってもうるう年ではない
if( year <= 1582 ) return TRUE; // ユリウス暦で 1582 年 2 月 24 日より前は、全ての 4 の倍数の年はうるう年であった
if( !( year % 400 )) return TRUE; // 閏世紀 は 400 で割り切れるうるう年
if( !( year % 100 )) return FALSE; // 2 世紀に 1 回はうるう年でない
return TRUE; // 4 で割り切れて世紀の区切りでなくユリウス暦でない場合、うるう年
}
便利なスニペット
ヘルパー関数
- Timestamp: list format to Unix timestamp - ex: [2009, 2, 13, 3, 31, 30] to 1234567890
- llParseString2List( llGetDate(), ["-"], [] ) (指定された日の最初の秒として表示される) と互換です
- Timestamp: Weekday from (Y, M, D) - ex: "Friday" from (Y, M, D)
関連項目
特記事項
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。