From 80a9436aa090c59a2fde1646c8f832b2d0215e39 Mon Sep 17 00:00:00 2001 From: Simon Hancock Date: Fri, 6 Dec 2024 22:04:54 +0000 Subject: [PATCH] Mavgen WLua: Pass unix time as integer to os.date --- generator/mavgen_wlua.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generator/mavgen_wlua.py b/generator/mavgen_wlua.py index afd3d4a10..7c5b85eac 100644 --- a/generator/mavgen_wlua.py +++ b/generator/mavgen_wlua.py @@ -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