Skip to content

Commit

Permalink
Formats Date and Time
Browse files Browse the repository at this point in the history
  • Loading branch information
rewanthtammana committed Jul 4, 2017
1 parent 127ea7c commit 419df0f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scripts/openwebnet-discovery.nse
Expand Up @@ -155,12 +155,16 @@ end
local function format_dimensions(res)

if res["Date and Time"] then
res["Date"] = string.match(res["Date and Time"], "((%d+)%.(%d+)%.(%d+))$")
local params = {
[0] = "hour", "min", "sec", "msec", "dayOfWeek", "year", "month", "day"
}

res["Time"] = string.match(res["Date and Time"], "^((%d+)%.(%d+)%.(%d+))")
res["Time"] = string.gsub(res["Time"], "%.", ":")
local values = {}
for counter, val in ipairs(stdnse.strsplit("%.%s*", res["Date and Time"])) do
values[ params[counter - 1] ] = val
end

res["Date and Time"] = nil
res["Date and Time"] = stdnse.format_timestamp(values)
end

if res["Device Type"] then
Expand Down

0 comments on commit 419df0f

Please sign in to comment.