MCPcopy Index your code
hub / github.com/yuin/gopher-lua / osTime

Function osTime

oslib.go:194–222  ·  view source on GitHub ↗
(L *LState)

Source from the content-addressed store, hash-verified

192}
193
194func osTime(L *LState) int {
195 if L.GetTop() == 0 {
196 L.Push(LNumber(time.Now().Unix()))
197 } else {
198 lv := L.CheckAny(1)
199 if lv == LNil {
200 L.Push(LNumber(time.Now().Unix()))
201 } else {
202 tbl, ok := lv.(*LTable)
203 if !ok {
204 L.TypeError(1, LTTable)
205 }
206 sec := getIntField(L, tbl, "sec", 0)
207 min := getIntField(L, tbl, "min", 0)
208 hour := getIntField(L, tbl, "hour", 12)
209 day := getIntField(L, tbl, "day", -1)
210 month := getIntField(L, tbl, "month", -1)
211 year := getIntField(L, tbl, "year", -1)
212 isdst := getBoolField(L, tbl, "isdst", false)
213 t := time.Date(year, time.Month(month), day, hour, min, sec, 0, time.Local)
214 // TODO dst
215 if false {
216 print(isdst)
217 }
218 L.Push(LNumber(t.Unix()))
219 }
220 }
221 return 1
222}
223
224func osTmpname(L *LState) int {
225 file, err := os.CreateTemp("", "")

Callers

nothing calls this directly

Calls 7

LNumberTypeAlias · 0.85
getIntFieldFunction · 0.85
getBoolFieldFunction · 0.85
CheckAnyMethod · 0.80
TypeErrorMethod · 0.80
PushMethod · 0.65
GetTopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…