Difference between revisions of "LlGetDate/ja"

From Second Life Wiki
Jump to navigation Jump to search
(New page: {{LSL_Function/ja |func_id=204|func_sleep=0.0|func_energy=10.0 |func=llGetDate|sort=GetDate|return_type=string |func_footnote=時間を"YYYY-MM-DDThh:mm:ss.ff..fZ"の形式で知りたい...)
 
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{LSL_Function/ja
{{LSL_Function/ja
|func_id=204|func_sleep=0.0|func_energy=10.0
|func_id=204|func_sleep=0.0|func_energy=10.0
|func=llGetDate|sort=GetDate|return_type=string
|func=llGetDate|sort=GetDate
|func_footnote=時間を"YYYY-MM-DDThh:mm:ss.ff..fZ"の形式で知りたい場合は[[llGetTimestamp/ja|llGetTimestamp]]を使います。
|func_footnote=時間を "YYYY-MM-DDThh:mm:ss.ff..fZ" の形式で知りたい場合は [[llGetTimestamp/ja|llGetTimestamp]] を使います。
|func_desc
|func_desc=UTC タイムゾーンでの現在の日付を "YYYY-MM-DD" 形式で返します。
|return_text="YYYY-MM-DD"形式でのUTCタイムゾーンの現在の日付
|spec
|spec
|caveats
|caveats
|constants
|constants
|examples=<lsl>
|examples=<source lang="lsl2">// 誕生日サプライズ
// Birthday surprise
default
default
{
{
Line 19: Line 17:
     timer()
     timer()
     {
     {
         if(llGetDate() == "1987-02-15")
         if(llGetDate() == "2009-02-15")
             llSetText("HAPPY BIRTHDAY!", <0,1,0>, 1.0);
             llSetText("HAPPY BIRTHDAY!", <0,1,0>, 1.0);
         else
         else
             llSetText("A surprise is comming...", <0,1,0>, 1.0);
             llSetText("A surprise is coming...", <0,1,0>, 1.0);
          
          
         llSetTimerEvent(3600);  // check every hour.
         llSetTimerEvent(3600.0);  // 毎時間チェックを行う
     }
     }
}</source>
<source lang="lsl2">// 通日を計算する関数
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));
}
}
</lsl>
 
|helpers
default
|also_functions={{LSL DefineRow||[[llGetTimestamp/ja|llGetTimestamp]]|同じ形式ですが、時間を併せます。}}
{
    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));
    }
}</source>
<source lang="lsl2">// うるう年かどうか計算する関数
 
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 で割り切れて世紀の区切りでなくユリウス暦でない場合、うるう年
}</source>
|helpers=
=== ヘルパー関数 ===
* [[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
** {{LSLG/ja|llParseString2List}}( {{LSLG/ja|llGetDate}}(), ["-"], [] ) (指定された日の最初の秒として表示される) と互換です
* [[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||{{LSLG/ja|llGetTimestamp}}|同じフォーマットですが、時刻も含みます}}
|also_events
|also_events
|also_tests
|also_tests
|also_articles={{LSL DefineRow||[http://www.cl.cam.ac.uk/~mgk25/iso-time.html ISO 8601]|}}
|also_articles={{LSL DefineRow||[http://www.cl.cam.ac.uk/~mgk25/iso-time.html ISO 8601]|}}
|notes
|notes
|permission
|negative_index
|cat1=Time
|cat1=Time
|cat2
|cat2

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