Difference between revisions of "LlGetDate/ja"

From Second Life Wiki
Jump to navigation Jump to search
 
Line 7: Line 7:
|caveats
|caveats
|constants
|constants
|examples=<lsl>// 誕生日サプライズ
|examples=<source lang="lsl2">// 誕生日サプライズ
default
default
{
{
Line 24: Line 24:
         llSetTimerEvent(3600.0);  // 毎時間チェックを行う
         llSetTimerEvent(3600.0);  // 毎時間チェックを行う
     }
     }
}</lsl>
}</source>
<lsl>// 通日を計算する関数
<source lang="lsl2">// 通日を計算する関数
integer dayOfYear(integer year, integer month, integer day)
integer dayOfYear(integer year, integer month, integer day)
{
{
Line 42: Line 42:
         llSay(0, "The current day of the year is " + (string) dayOfYear(year, month, day));
         llSay(0, "The current day of the year is " + (string) dayOfYear(year, month, day));
     }
     }
}</lsl>
}</source>
<lsl>// うるう年かどうか計算する関数
<source lang="lsl2">// うるう年かどうか計算する関数


integer is_leap_year( integer year )  
integer is_leap_year( integer year )  
Line 52: Line 52:
     if( !( year % 100 ))  return FALSE;  // 2 世紀に 1 回はうるう年でない
     if( !( year % 100 ))  return FALSE;  // 2 世紀に 1 回はうるう年でない
     return TRUE;                          // 4 で割り切れて世紀の区切りでなくユリウス暦でない場合、うるう年
     return TRUE;                          // 4 で割り切れて世紀の区切りでなくユリウス暦でない場合、うるう年
}</lsl>
}</source>
|helpers=
|helpers=
=== ヘルパー関数 ===
=== ヘルパー関数 ===

Latest revision as of 14:45, 25 February 2016

要約

関数: 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の関連した項目が参考になるかもしれません。