For the latest stable version, please use Emilua API 0.10!

time.system_clock

local clock = require('time').system_clock
local timepoint = clock.now()

The system-wide real time wall clock. It uses the UNIX epoch.

On most systems, the system time can be adjusted at any moment.

Functions

now() → system_clock.time_point

Returns a new time point representing the current value of the clock.

epoch() → system_clock.time_point

Returns a new time point representing the epoch of the clock.

time_point functions

add(self, secs: number)

Modifies the time point by the given duration.

When the duration is converted to the native tick representation of the clock, it’ll be rounded to the nearest time point rounding to even in halfway cases.

sub(self, secs: number)

Modifies the time point by the given duration.

When the duration is converted to the native tick representation of the clock, it’ll be rounded to the nearest time point rounding to even in halfway cases.

time_point properties

seconds_since_epoch: number

The number of elapsed seconds since 1 January 1970, not counting leap seconds.

time_point metamethods

  • __add()

  • __sub()

  • __eq()

  • __lt()

  • __le()