Timeutils
Package that handles ingame and real world time.
Including Code
Все функции отвечающие за вывод времени в игре.
include ":timeutils:gameTime";
CONST
enum TIME_UNITS
// Base unit: Millisecond
MIL_SECOND := 1000,
MIL_MINUTE := MIL_SECOND * 60,
MIL_HOUR := MIL_MINUTE * 60,
MIL_DAY := MIL_HOUR * 24,
MIL_WEEK := MIL_DAY * 7,
MIL_MONTH := MIL_DAY * 30,
MIL_YEAR := MIL_MONTH * 12,
// Base unit: Second
SEC_MINUTE := 60,
SEC_HOUR := SEC_MINUTE * 60,
SEC_DAY := SEC_HOUR * 24,
SEC_WEEK := SEC_DAY * 7,
SEC_MONTH := SEC_DAY * 30,
SEC_YEAR := SEC_DAY * 365,
// SleepMs value to prevent RunAway
NO_RUNAWAY := 10
endenum
GetTime()
Returns current UNIX time stamp. Example: 1609429618
GetTimeStruct(time)
Returns current time as struct: day
, month
, year
, hour
, minute
, second
var ts := GetTimeStruct( GetTime() );
ts.year ts.month ts.day ts.hour ts.minute ts.second
// 2020 12 31 18 16 00
FormatTime(byref time_struct, format)
Returns a formatted time string.
Parameters
Description
time_struct:
The time struct to use as base
format:
The format string. The following tags will be expanded:
<Y>: Year
<M>: Month name, <m>: Month number
<d>: Day number
<h>: Hour, <i>: Minute, <s>: Second
FormatTime(GetTimeStruct(GetTime()), "[<m>/<d> <h>:<i>]");
// Print: [12/31 18:20]
Month
GetMonthName(month)
Convert the month number to the month's abbreviated name.
var ts := GetTimeStruct( GetTime() );
GetMonthName( ts.month );
// Print: "Jan", "Feb", "Mar", "Apr" ...
GetMonthFullName(month)
Convert the month number to the month's name.
var ts := GetTimeStruct( GetTime() );
GetMonthFullName( ts.month );
// Print: "January", "February", "March" ....
GetMonthOrdinal(month)
Convert the month's name or abbreviation to the ordinal number of the month.
GetMonthOrdinal( "january" ); // Print: '01'
GetMonthLength(month, year := 0)
Returns the length of the month in days
GetMonthLength( 2, 2020 ); // Print: 29
GetMonthDifferential( byref current_month, byref previous_month )
Returns the difference between month_1 and month_2 The intended use of this function is to determine the number of months that have elapsed between current_month and previous_month.
GetMonthDifferential( byref current_month, byref previous_month );
Не работает на нашем сервере, необходимо добавить функцию Abs();
Other
IsLeap()
Returns whether a year is a leap year or not.
IsLeap(year);
GetCurrentPlaytimeMonth()
Возвращает текущий месяц формата: 2017_april_play_time
для Statictics
GetCurrentPlaytimeMonth();
Last updated
Was this helpful?