Module ui.timeval

A simple module to module to compare and do arithmetic with time values.

Usage:

    local TimeVal = require("ui/timeval")
    
    local tv_start = TimeVal:now()
    -- Do some stuff.
    -- You can add and subtract `TimeVal` objects.
    local tv_duration = TimeVal:now() - tv_start
    -- If you need more precision (like 2.5 s),
    -- you can add the milliseconds to the seconds.
    local tv_duration_seconds_float = tv_duration.sec + tv_duration.usec/1000000
    

Functions

TimeVal:new (from_o) Creates a new TimeVal object.
TimeVal:now () Creates a new TimeVal object based on the current time.

Tables

TimeVal TimeVal object.


Functions

TimeVal:new (from_o)
Creates a new TimeVal object.

Parameters:

  • from_o

Returns:

    TimeVal

Usage:

    local timev = TimeVal:new{
        sec = 10,
        usec = 10000,
    }
TimeVal:now ()
Creates a new TimeVal object based on the current time.

Returns:

    TimeVal

Usage:

    local TimeVal = require("ui/timeval")
    local tv_start = TimeVal:now()
    -- Do some stuff.
    -- You can add and substract TimeVal objects.
    local tv_duration = TimeVal:now() - tv_start

Tables

TimeVal
TimeVal object.

Fields:

  • sec int floored number of seconds
  • usec int remaining number of milliseconds
generated by LDoc 1.4.6 Last updated 2017-10-08 14:57:40