Skip to content

Instantly share code, notes, and snippets.

@steelman
Created May 2, 2015 10:17
Show Gist options
  • Save steelman/e57b3ec09e8f55ba9106 to your computer and use it in GitHub Desktop.
Save steelman/e57b3ec09e8f55ba9106 to your computer and use it in GitHub Desktop.
Test for timestamp parsing in metar.lua library
-- This is a code to test timestamp parsing in metar.lua library[1].
-- The original version (up to d99521d5) failed because mktime(3)
-- and os.date() expect local time as input.
--
-- [1] https://github.com/steelman/metar
function print_now(now)
print (string.format('now => %d', now))
print (string.format("local: %s",os.date('%Y-%m-%d %H:%M:%S', now)))
print (string.format("UTC: %s",os.date('!%Y-%m-%d %H:%M:%S', now)))
end
time = os.time()
print_now(time)
print ('---')
require ('metar')
m = metar.new('FOOO')
date = os.date('!*t', time)
s = string.format('FOOO %02d%02d%02dZ', date.day, date.hour, date.min)
d = m:_parse_metar_string(s)
print_now(d.timestamp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment