mirror of
https://github.com/nmap/nmap.git
synced 2026-08-30 13:42:59 +00:00
Allow stdnse.format_timestamp to take a Lua date table
This will allow formatting of timestamps beyond 2036, which currently are limited by the wrapping of the 32-bit Unix timestamp.
This commit is contained in:
parent
8b88b60c49
commit
125d84fd67
1 changed files with 10 additions and 3 deletions
|
|
@ -446,9 +446,16 @@ end
|
|||
-- This function should be used for all dates emitted as part of NSE structured
|
||||
-- output.
|
||||
function format_timestamp(t, offset)
|
||||
local tz_string = format_tz(offset)
|
||||
offset = offset or 0
|
||||
return os.date("!%Y-%m-%dT%H:%M:%S", t + offset) .. tz_string
|
||||
if type(t) == "table" then
|
||||
return string.format(
|
||||
"%d-%02d-%02dT%02d:%02d:%02d",
|
||||
t.year, t.month, t.day, t.hour, t.min, t.sec
|
||||
)
|
||||
else
|
||||
local tz_string = format_tz(offset)
|
||||
offset = offset or 0
|
||||
return os.date("!%Y-%m-%dT%H:%M:%S", t + offset) .. tz_string
|
||||
end
|
||||
end
|
||||
|
||||
--- Format the difference between times <code>t2</code> and <code>t1</code>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue