lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Den 2012-04-13 10:16, skrev Rena:
Does Lua provide a way to turn a table into a Unix timestamp
under the assumption that the table specifies GMT, not the local
timezone?

If you can assume unix time, the following seem to work:


local epoch = {year=1970, month=1, day=1, hour=0, min=0, sec=0, isdst=false }
function gmtime(t)
  t.isdst =  false
  return os.time(t) - os.time(epoch)
end


For os.time(t) I found that t.isdst=false means force 'no DST', while t.isdst=nil means assume DST as known for that day. Perhaps a note in the Lua reference manual would be good?

BR
egil