Module os
Operating System Facilities.
This library is implemented through table os.
Type os
os.clock() |
Returns an approximation of the amount in seconds of CPU time used by the program. |
os.date(format, time) |
Returns a string or a table containing date and time, formatted according
to the given string |
os.difftime(t2, t1) |
Returns the number of seconds from time |
os.time(table) |
Returns the current time when called without arguments, or a time representing the date and time specified by the given table. |
Type os
Field(s)
- os.clock()
-
Returns an approximation of the amount in seconds of CPU time used by the program.
Return value
#number: the amount in seconds of CPU time used by the program.
- os.date(format, time)
-
Returns a string or a table containing date and time, formatted according to the given string
format
.If the
time
argument is present, this is the time to be formatted (see theos.time
function for a description of this value). Otherwise,date
formats the current time.If
format
starts with '!
', then the date is formatted in Coordinated Universal Time. After this optional character, ifformat
is the string "*t
", thendate
returns a table with the following fields:year
(four digits)month
(1--12)day
(1--31)hour
(0--23)min
(0--59)sec
(0--61)wday
(weekday, Sunday is 1)yday
(day of the year)isdst
(daylight saving flag, a boolean).
If
format
is not "*t
", thendate
returns the date as a string, formatted according to the same rules as the C functionstrftime
. 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 toos.date("%c")
).Parameters
-
#string format
: format of date. (optional) -
#number time
: time to format. (default value is current time)
Return value
#string: a formatted string representation of
time
.
- os.difftime(t2, t1)
-
Returns the number of seconds from time
t1
to timet2
.In POSIX, Windows, and some other systems, this value is exactly
t2
-t1
.Parameters
-
#number t2
: -
#number t1
:
Return value
#number: the number of seconds from time
t1
to timet2
. -
- os.time(table)
-
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
, andday
, and may have fieldshour
,min
,sec
, andisdst
(for a description of these fields, see theos.date
function).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 todate
anddifftime
.Parameter
-
#table table
: a table which describes a date.
Return value
#number: a number meaning a date.
-