Convert string to date

Try:

function M.makeTimeStamp(dateString, mode)     local pattern = "(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)([%+%-])(%d+)%:(%d+)"     local xyear, xmonth, xday, xhour, xminute, xseconds, xoffset, xoffsethour, xoffsetmin     local monthLookup = {Jan = 1, Feb = 2, Mar = 3, Apr = 4, May = 5, Jun = 6, Jul = 7, Aug = 8, Sep = 9, Oct = 10, Nov = 11, Dec = 12}     local convertedTimestamp     local offset = 0     if mode and mode == "ctime" then         pattern = "%w+ (%w+) (%d+) (%d+):(%d+):(%d+) (%w+) (%d+)"         local monthName, TZName         monthName, xday, xhour, xminute, xseconds, TZName, xyear = dateString:match(pattern)         xmonth = monthLookup[monthName]         convertedTimestamp = os.time({year = xyear, month = xmonth,         day = xday, hour = xhour, min = xminute, sec = xseconds})     else         xyear, xmonth, xday, xhour, xminute, xseconds, xoffset, xoffsethour, xoffsetmin = dateString:match(pattern)         convertedTimestamp = os.time({year = xyear, month = xmonth,         day = xday, hour = xhour, min = xminute, sec = xseconds})         offset = xoffsethour \* 60 + xoffsetmin         if xoffset == "-" then offset = offset \* -1 end     end     return convertedTimestamp + offset end

That above date works with dates that have Z timezone info, not +offset type dates.  This version should work (pulled it from code I use in my IAP based apps)…

Rob