oslib

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: Apache-2.0, MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgToTime

func ArgToTime(t *rt.Thread, c *rt.GoCont, n int) (time.Time, error)

ArgToTime converts the n-th argument to a time. If the value is nil then the current time will be returned; if the value is an integer then it will be assumed to represent a UNIX time; if the value is a table then TableToTime will be used to perform the conversion.

Note that the returned time will be given in the location determined by Location.

func Date

func Date(format string, when time.Time, t *rt.Thread) rt.Value

Date returns a Lua value corresponding to the given time and format.

Note that the formatting will take place relative to the location determined by Location, unless the first character in the format string is "!", in which case UTC is used for the location.

func Location

func Location(t *rt.Thread) *time.Location

Location returns the current location for date/time operations, as set by the os.setlocale function.

func TableToTime

func TableToTime(t *rt.Thread, v *rt.Table) (time.Time, error)

TableToTime convert the given table v to a time. The table may have fields:

year 				(required)
month (1–12) 		(required)
day (1–31)	 		(required)
hour (0–23)	 		(default: 12)
min (0–59)	 		(default: 0)
sec (0–61)	 		(default: 0)
millisec (0-999)	(default: 0)

If any required field is missing or nil, then an error will be returned. The values for month, day, hour, min, and sec may be outside their usual ranges and will be normalised during the conversion. For example, October 32 converts to November 1.

Note that the conversion will take place relative to the location determined by Location.

func TimeToTable

func TimeToTable(when time.Time) *rt.Table

TimeToTable converts the given time to a table. The following fields will be set on the returned table:

year
month (1–12)
day (1–31)
hour (0–23)
min (0–59)
sec (0–61)
millisec (0-999)
wday (weekday, 1–7, Sunday is 1)
yday (day of the year, 1–366)

Note that the conversion will take place relative to the time's location. If you need this to be relative to the location set by the user, do

TimeToTable(when.In(Location(t)))

where t is the current thread.

Types

This section is empty.

Jump to

Keyboard shortcuts

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