Time
Operators and functions for working with date and time (time type) are described here.
Types
time
The time type has the following fields:
int Year - year
int Month - month
int Day - day of month
int Hour - hour
int Minute - minute
int Second - second
bool UTC - if it is true, then it is UTC time, otherwise it is local time.
Operators
Functions
int(time t) int
The int function converts time value to a Unix time, the number of seconds elapsed since January 1, 1970 UTC and returns it.
time(int unixtime) time
The time function converts the given Unix time, sec seconds since January 1, 1970 UTC to time structure and returns it.
AddHours(time t, int hours) time
The AddHours function returns the time corresponding to adding the given number of hours to t. The hours parameter can be negative.
Date(int year month day) time
The Date function returns a structure of the time type with the specified date.
DateTime(int year month day hour minute second) time
The DateTime function returns the time structure as local time. Also, you can initialize a time variable like this
Days(time t) int
The Days function returns the number of days in the month in which the specified time is located.
Format(str layout, time t) str
The Format function returns a textual representation of the time value formatted according to layout. It takes a string of tokens and replaces them with their corresponding values.
Now() time
The Now function returns the current local time.
ParseTime(str layout, str value) time
The ParseTime function parses a formatted string and returns the time value it represents. The list of layout tokens is the same as in Format function.
str(time t) str
The str converts the specified time to a string in the format YYYY-MM-DD HH:mm:ss.
UTC(time t) time
The UTC function converts local time to UTC and returns a new time structure. If the time t was already UTC, then a copy of it is returned.
Weekday(time t) int
The Weekday function returns the day of the week specified by t. 0 - Sunday, 1 - Monday etc.
YearDay(time t) int
The YearDay function returns the day of the year specified by t.
Last updated