Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mavgen WLua: Pass unix time as integer to os.date #997

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions generator/mavgen_wlua.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ def generate_preamble(outf):
-- function to append human-readable time onto unix_time_us fields
local function time_usec_decode(value)
if value > time_usec_threshold then
d = os.date("%Y-%m-%d %H:%M:%S",value:tonumber() / 1000000.0)
s = math.floor(value:tonumber() / 1000000.0)
us = value % 1000000
d = os.date("%Y-%m-%d %H:%M:%S",s)
us = string.format("%06d",us:tonumber())
ok, tz = pcall(os.date," %Z",value:tonumber() / 1000000.0)
ok, tz = pcall(os.date," %Z",s)
if not ok then
tz = os.date(" %z",value:tonumber() / 1000000.0)
tz = os.date(" %z",s)
end
return " (" .. d .. "." .. us .. tz .. ")"
elseif value < 1000000 then
Expand Down
Loading