time

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

README

time GoDoc

Lua module for time.

Usage

local time = require("time")

-- time.unix(), time.sleep()
local begin = time.unix()
time.sleep(1.2)
local stop = time.unix()
local result = stop - begin
result = math.floor(result * 10^2 + 0.5) / 10^2
if not(result == 1) then error("time.sleep()") end

-- time.parse(value, layout)
local result, err = time.parse("Dec  2 03:33:05 2018", "Jan  2 15:04:05 2006")
if err then error(err) end
if not(result == 1543721585) then error("time.parse()") end

-- time.format(value, layout, location)
local result, err = time.format(1543721585, "Jan  2 15:04:05 2006", "Europe/Moscow")
if err then error(err) end
if not(result == "Dec  2 06:33:05 2018") then error("time.format()") end

Documentation

Overview

Package time implements golang package time functionality for lua.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(L *lua.LState) int

Format lua time.format(unixts, ...layout, ...location) returns (string, err)

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func Parse

func Parse(L *lua.LState) int

Parse lua time.parse(value, layout, ...location) returns (number, error)

func Preload

func Preload(L *lua.LState)

Preload adds time to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local time = require("time")

func Sleep

func Sleep(L *lua.LState) int

Sleep lua time.sleep(number) port of go time.Sleep(int64)

func Unix

func Unix(L *lua.LState) int

Unix lua time.unix() returns unix timestamp in seconds (float)

func UnixNano

func UnixNano(L *lua.LState) int

UnixNano lua time.unix_nano() returns unix timestamp in nano seconds

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL