Module time



Time methods


Time()
Return the current time.

Time(year, month = 1, day = 1, hour = 0, minute = 0, Float second = 0)
Constructs a Time object from specified arguments.

unix_time()
Return seconds since the epoch as a floating point number.

strftime(format)
Return a string representing the time, controlled by an explicit format string. For a complete list of formatting directives, see https://en.cppreference.com/w/c/chrono/strftime.

format(fmt)
Similar to
strftime()
, but format is much simpler:
YYYYyear, e.g. 2018
YYlast 2 digits of year, e.g. 18
MMmonth (range [01, 12])
DDday of the month (range [01, 31])
hhhour in 24h format (range [00, 23])
mmminute (range [00, 59])
sssecond (range [00, 60])


TimeDelta methods and members


TimeDelta(', days = 0, hours = 0, minutes = 0, seconds = 0, milliseconds = 0, microseconds = 0, weeks = 0)
Constructor.

seconds
Number of seconds.

days()
Number of days.

The following operators are supported:
Time - Time -> TimeDelta
Time + TimeDelta -> Time
Time - TimeDelta -> Time


time functions


time:today()
Return the current time as
Time(current_year, current_month, current_day)
.

time:from_unix_time(Float seconds_since_the_epoch)
Return a Time object corresponding to the POSIX timestamp (i.e. seconds since the epoch).

time:strptime(string, format) -> Time
Parse a string representing a time according to a format.
The
format
parameter uses the same directives as those used by
Time.strftime()
.

time:perf_counter()
Return the value of a performance counter, i.e. a clock with the highest available resolution to measure a short duration.
It can be used as follows:
V start = time:perf_counter()
...
print(‘Elapsed: ’(time:perf_counter() - start)‘ seconds’)