“LlGetGMTclock”的版本间的差异

来自人工智能助力教育知识百科
跳转至: 导航搜索
(创建页面,内容为“123r2”)
 
Qmf讨论 | 贡献
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
123r2
+
{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}}
 +
 
 +
 
 +
{{函数详情
 +
|函数名 = Function: float llGetGMTclock( )
 +
|参数= 参数:
 +
|返回值= 返回值:返回一个浮点数,以秒为单位表示从格林尼治时间午夜开始的时间。值似乎被截断为秒。
 +
 
 +
|注意事项=
 +
注意事项
 +
 
 +
 
 +
|示例=
 +
<pre>
 +
//--// GMT function with local offsets in 12hr format //--//
 +
 +
integer gIntMinute = 60;    //-- 1 minute in seconds
 +
integer gIntHour  = 3600;  //-- 1 hour in seconds
 +
integer gInt12Hr  = 43200; //-- 12hrs in seconds
 +
integer gIntDay    = 86400; //-- 1 day in seconds
 +
 +
string fStrGMTwOffset( integer vIntLocalOffset ){
 +
  //-- get the correct time in seconds for the given offset
 +
  integer vIntBaseTime = ((integer)llGetGMTclock() + gIntDay + vIntLocalOffset * gIntHour) % gIntDay;
 +
  string vStrReturn;
 +
 +
  //-- store morning or night and reduce to 12hour format if needed
 +
  if (vIntBaseTime < gInt12Hr){
 +
    vStrReturn = " AM";
 +
  }else{
 +
    vStrReturn = " PM";
 +
    vIntBaseTime = vIntBaseTime % gInt12Hr;
 +
  }
 +
 +
  //-- get and format minutes
 +
  integer vIntMinutes = (vIntBaseTime % gIntHour) / gIntMinute;
 +
  vStrReturn = (string)vIntMinutes + vStrReturn;
 +
  if (10 > vIntMinutes){
 +
    vStrReturn = "0" + vStrReturn;
 +
  }
 +
 +
  //-- add in the correct hour, force 0 to 12
 +
  if (vIntBaseTime < gIntHour){
 +
    vStrReturn = "12:" + vStrReturn;
 +
  }else{
 +
    vStrReturn = (string)(vIntBaseTime / gIntHour) + ":" + vStrReturn;
 +
  }
 +
  return vStrReturn;
 +
}
 +
 +
default{
 +
  touch_start( integer vIntTouched ){
 +
    //-- '-8' is california time, no adjustment for DST
 +
    llSay( 0, "The time is now " + fStrGMTwOffset( -8 ) );
 +
  }
 +
}
 +
</pre>
 +
<pre>
 +
// Gets the number of milliseconds since midnight UTC.
 +
integer GetGMTmsclock()
 +
{
 +
    string stamp = llGetTimestamp();
 +
    return
 +
        (integer) llGetSubString(stamp, 11, 12) * 3600000 +
 +
        (integer) llGetSubString(stamp, 14, 15) * 60000 +
 +
        llRound((float) llGetSubString(stamp, 17, -2) * 1000.0);
 +
}
 +
</pre>
 +
 
 +
|相关函数=
 +
[[llGetWallclock]]–从午夜SLT(即PST或PDT)开始的秒数
 +
 
 +
|相关事件=
 +
 +
 
 +
}}

2021年1月25日 (一) 07:53的最新版本

Template:Needs Translation/


函数名
Function: float llGetGMTclock( )
参数:
返回值:返回一个浮点数,以秒为单位表示从格林尼治时间午夜开始的时间。值似乎被截断为秒。
注意事项
注意事项
示例
//--// GMT function with local offsets in 12hr format //--//
 
integer gIntMinute = 60;    //-- 1 minute in seconds
integer gIntHour   = 3600;  //-- 1 hour in seconds
integer gInt12Hr   = 43200; //-- 12hrs in seconds
integer gIntDay    = 86400; //-- 1 day in seconds
 
string fStrGMTwOffset( integer vIntLocalOffset ){
   //-- get the correct time in seconds for the given offset
  integer vIntBaseTime = ((integer)llGetGMTclock() + gIntDay + vIntLocalOffset * gIntHour) % gIntDay;
  string vStrReturn;
 
   //-- store morning or night and reduce to 12hour format if needed
  if (vIntBaseTime < gInt12Hr){
    vStrReturn = " AM";
  }else{
    vStrReturn = " PM";
    vIntBaseTime = vIntBaseTime % gInt12Hr;
  }
 
   //-- get and format minutes
  integer vIntMinutes = (vIntBaseTime % gIntHour) / gIntMinute;
  vStrReturn = (string)vIntMinutes + vStrReturn;
  if (10 > vIntMinutes){
    vStrReturn = "0" + vStrReturn;
  }
 
   //-- add in the correct hour, force 0 to 12
  if (vIntBaseTime < gIntHour){
    vStrReturn = "12:" + vStrReturn;
  }else{
    vStrReturn = (string)(vIntBaseTime / gIntHour) + ":" + vStrReturn;
  }
  return vStrReturn;
}
 
default{
  touch_start( integer vIntTouched ){
     //-- '-8' is california time, no adjustment for DST
    llSay( 0, "The time is now " + fStrGMTwOffset( -8 ) );
  }
}
// Gets the number of milliseconds since midnight UTC.
integer GetGMTmsclock()
{
    string stamp = llGetTimestamp();
    return
        (integer) llGetSubString(stamp, 11, 12) * 3600000 +
        (integer) llGetSubString(stamp, 14, 15) * 60000 +
        llRound((float) llGetSubString(stamp, 17, -2) * 1000.0);
}
相关函数
llGetWallclock–从午夜SLT(即PST或PDT)开始的秒数
相关事件