Scripting/Squirrel/Client Functions/System::GetDate: Difference between revisions
		
		
		
		Jump to navigation
		Jump to search
		

This wiki is using an old backup from 2020
Some information may be old/missing
|  (Created page with "This function returns a table containing a date/time splitted in the slots. It follows same syntax as the Squirrel standard library's date function: [http://squirrel-lang.org/...") | No edit summary | ||
| Line 1: | Line 1: | ||
| This function returns a table containing a date/time splitted in  | This function returns a table containing a date/time splitted as in table below '''Return type'''. It follows same syntax as the Squirrel standard library's date function: [http://squirrel-lang.org/squirreldoc/stdlib/stdsystemlib.html#date] | ||
| == Syntax == | == Syntax == | ||
Revision as of 16:54, 28 September 2018
This function returns a table containing a date/time splitted as in table below Return type. It follows same syntax as the Squirrel standard library's date function: [1]
Syntax
System.GetDate([time], [format]])
time and format are optional.
Return type
table
| Name | Description | 
|---|---|
| sec | Seconds after minute (0 - 59) | 
| min | Minutes after hour (0 - 59) | 
| hour | Hours since midnight (0 - 23) | 
| day | Day of month (1 - 31) | 
| month | Month (0 - 11; January = 0) | 
| year | Year (current year) | 
| wday | Day of week (0 - 6; Sunday = 0) | 
| yday | Day of year (0 - 365; January 1 = 0) | 
Example
/* Player::PlayerDeath is triggered whenever someone die */
function Player::PlayerDeath( player ) 
{
      /* Check whether the player that just died is local player/self */
      if ( player.ID == World.FindLocalPlayer().ID )
      {
            local now = System.GetDate(); 
            // hour:minute:sec
            local ftTime = format( "%i:%i:%i", now.hour, now.min, now.sec ); 
            /* Show the time of player's death to local player/self. This is just for example */ 
            Console.Print( player.Name +" died at "+ ftTime );
      }
}Notes
Player::PlayerDeath, World::FindLocalPlayer and Console::Print were used in this example, more info about them in the corresponding pages.