This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Processing Australian BOM Weather XML Data
#4
You can get start/end time as Lua table like this. Then you can either convert it to timestamp via os.time() or use it as object value directly.

Code:
function parsedatetime(str)
  local date = {}

  date.year, date.month, date.day,
  date.hour, date.min, date.sec =
    str:match('(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)')

  return date
end

function starttag(p, tag, attrs)
  if tag == 'area' and attrs.aac == aac then
    in_area = true
  elseif tag == 'forecast-period' and in_area then
    index = tonumber(attrs.index)

    if index then
      forecast[ index ] = {
        start_time = parsedatetime(attrs['start-time-local']),
        end_time = parsedatetime(attrs['end-time-local']),
      }
    end
  elseif index then
    prop = attrs.type
  end
end

-- start_time = forecast[ 1 ].start_time
-- end_time = forecast[ 1 ].end_time
Reply


Messages In This Thread
RE: Processing Australian BOM Weather XML Data - by admin - 16.01.2019, 13:00

Forum Jump: