Home Explore Blog CI



neovim

72th chunk of `runtime/doc/luaref.txt`
244e87394109da955fa117ae7469be2d8da66479fcdf05130000000100000fa6
 `strftime`.

        When called without arguments, `date` returns a reasonable date and
        time representation that depends on the host system and on the current
        locale (that is, `os.date()` is equivalent to `os.date("%c")`).

os.difftime({t2}, {t1})                                          *os.difftime()*
        Returns the number of seconds from time {t1} to time {t2}. In POSIX,
        Windows, and some other systems, this value is exactly `t2 - t1` .

os.execute([{command}])                                           *os.execute()*
        This function is equivalent to the C function `system`. It passes
        {command} to be executed by an operating system shell. It returns a
        status code, which is system-dependent. If {command} is absent, then
        it returns nonzero if a shell is available and zero otherwise.

os.exit([{code}])                                                    *os.exit()*
        Calls the C function `exit`, with an optional {code}, to terminate the
        host program. The default value for {code} is the success code.

os.getenv({varname})                                               *os.getenv()*
        Returns the value of the process environment variable {varname}, or
        `nil` if the variable is not defined.

os.remove({filename})                                              *os.remove()*
        Deletes the file with the given name. Directories must be empty to be
        removed. If this function fails, it returns `nil`, plus a string
        describing the error.

os.rename({oldname}, {newname})                                    *os.rename()*
        Renames file named {oldname} to {newname}. If this function fails, it
        returns `nil`, plus a string describing the error.

os.setlocale({locale} [, {category}])                           *os.setlocale()*
        Sets the current locale of the program. {locale} is a string
        specifying a locale; {category} is an optional string describing which
        category to change: `"all"`, `"collate"`, `"ctype"`, `"monetary"`,
        `"numeric"`, or `"time"`; the default category is `"all"`. The
        function returns the name of the new locale, or `nil` if the request
        cannot be honored.

os.time([{table}])                                                   *os.time()*
        Returns the current time when called without arguments, or a time
        representing the date and time specified by the given table. This
        table must have fields `year`, `month`, and `day`, and may have fields
        `hour`, `min`, `sec`, and `isdst` (for a description of these fields,
        see the `os.date` function |os.date()|).

        The returned value is a number, whose meaning depends on your system.
        In POSIX, Windows, and some other systems, this number counts the
        number of seconds since some given start time (the "epoch"). In other
        systems, the meaning is not specified, and the number returned by
        `time` can be used only as an argument to `date` and `difftime`.

os.tmpname()                                                      *os.tmpname()*
        Returns a string with a file name that can be used for a temporary
        file. The file must be explicitly opened before its use and explicitly
        removed when no longer needed.

==============================================================================
5.9  The Debug Library                                         *lua-lib-debug*

This library provides the functionality of the debug interface to Lua
programs. You should exert care when using this library. The functions
provided here should be used exclusively for debugging and similar tasks, such
as profiling. Please resist the temptation to use them as a usual programming
tool: they can be very slow. Moreover, several of its functions violate some
assumptions about Lua code (e.g., that variables local to a function cannot be
accessed from outside or that userdata metatables

Title: Lua OS Library: Environment, File Manipulation, Locale, Time, and Debug Library Introduction
Summary
This section details the Lua `os` library, covering functions like `os.getenv` for retrieving environment variables, `os.remove` for deleting files, `os.rename` for renaming files, `os.setlocale` for setting the program's locale, `os.time` for getting the current time or a time from a table, and `os.tmpname` for generating temporary file names. It also introduces the `debug` library, cautioning its use for debugging and profiling due to potential performance issues and assumption violations about Lua code.