mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 07:33:21 -05:00
lua: Add date.now()
This commit is contained in:
parent
16a8316c70
commit
75fa8ee28a
@ -13,6 +13,7 @@ func luaRegisterDates(L *lua.LState) {
|
|||||||
mt := L.NewTypeMetatable(luaDateTypeName)
|
mt := L.NewTypeMetatable(luaDateTypeName)
|
||||||
L.SetGlobal("date", mt)
|
L.SetGlobal("date", mt)
|
||||||
L.SetField(mt, "new", L.NewFunction(luaDateNew))
|
L.SetField(mt, "new", L.NewFunction(luaDateNew))
|
||||||
|
L.SetField(mt, "now", L.NewFunction(luaDateNow))
|
||||||
L.SetField(mt, "__tostring", L.NewFunction(luaDate__tostring))
|
L.SetField(mt, "__tostring", L.NewFunction(luaDate__tostring))
|
||||||
L.SetField(mt, "__eq", L.NewFunction(luaDate__eq))
|
L.SetField(mt, "__eq", L.NewFunction(luaDate__eq))
|
||||||
L.SetField(mt, "__lt", L.NewFunction(luaDate__lt))
|
L.SetField(mt, "__lt", L.NewFunction(luaDate__lt))
|
||||||
@ -85,6 +86,13 @@ func luaDateNew(L *lua.LState) int {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func luaDateNow(L *lua.LState) int {
|
||||||
|
now := time.Now()
|
||||||
|
date := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
|
||||||
|
L.Push(TimeToLua(L, &date))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
func luaDate__tostring(L *lua.LState) int {
|
func luaDate__tostring(L *lua.LState) int {
|
||||||
a := luaCheckTime(L, 1)
|
a := luaCheckTime(L, 1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user