Skip to content

Commit

Permalink
Mavgen WLua: Pass unix time as integer to os.date
Browse files Browse the repository at this point in the history
  • Loading branch information
shancock884 committed Dec 6, 2024
1 parent 6e1da0a commit 80a9436
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 80a9436

Please sign in to comment.