Skip to content

oslib

clock

function os.clock()
  -> number

Returns an approximation of the amount in seconds of CPU time used by the program.

View documents

date

function os.date(format?: string, time?: integer)
  -> string|osdate

Returns a string or a table containing date and time, formatted according to the given string format.

View documents

difftime

function os.difftime(t2: integer, t1: integer)
  -> integer

Returns the difference, in seconds, from time t1 to time t2.

View documents

execute

function os.execute(command?: string)
  -> suc: boolean?
  2. exitcode: ("exit"|"signal")?
  3. code: integer?

Passes command to be executed by an operating system shell.

View documents

exitcode:
    | "exit"
    | "signal"

exit

function os.exit(code?: boolean|integer, close?: boolean)

Calls the ISO C function exit to terminate the host program.

View documents

getenv

function os.getenv(varname: string)
  -> string?

Returns the value of the process environment variable varname.

View documents

remove

function os.remove(filename: string)
  -> suc: boolean
  2. errmsg: string?

Deletes the file with the given name.

View documents

rename

function os.rename(oldname: string, newname: string)
  -> suc: boolean
  2. errmsg: string?

Renames the file or directory named oldname to newname.

View documents

setlocale

function os.setlocale(locale: string|nil, category?: "all"|"collate"|"ctype"|"monetary"|"numeric"...(+1))
  -> localecategory: string

Sets the current locale of the program.

View documents

category:
   -> "all"
    | "collate"
    | "ctype"
    | "monetary"
    | "numeric"
    | "time"

time

function os.time(date?: osdateparam)
  -> integer

Returns the current time when called without arguments, or a time representing the local date and time specified by the given table.

View documents

tmpname

function os.tmpname()
  -> string

Returns a string with a file name that can be used for a temporary file.

View documents