LlGetDate/ja

From Second Life Wiki
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.

要約

関数: 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 で割り切れて世紀の区切りでなくユリウス暦でない場合、うるう年
}

便利なスニペット

ヘルパー関数

関連項目

関数

•  llGetTimestamp 同じフォーマットですが、時刻も含みます

記事

•  ISO 8601

特記事項

Search JIRA for related Issues

Signature

function void llGetDate();
この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。