So I’m rolling with Rob Miracle’s tutorial on IAP. Specifically, I’ve used the timestamp code. And most of the time it works fine. But if I attempt to use on a Google Play device, I get an error that “field ‘day’ cannot be found” on all transactions/restores.
[lua]-- event.transaction.date shows as:
“Sat Mar 15 22:57:04 GMT+08:00 2014”[/lua]
Here’s the command being passed to timestamp:
[lua]local timeStamp = shop.makeTimeStamp(event.transaction.date, “ctime”)
if timeStamp + 360 < os.time() then
state = “restored”
restoring = false
end
[/lua]
And here’s the timestamp code I used. Rob, one of the comments had the exact same bug, and you said you updated the tutorial, but…not for this? (Hard to tell, I just can’t read any of the string pattern)
[lua]function shop.makeTimeStamp(dateString, mode)
local pattern = “(%d+)%-(%d+)%-(%d+)%a(%d+)% :(%d+)% :([%d%.]+)([Z%p])(%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+%s+(%w+)%s+(%d+)%s+(%d+)% :(%d+)% :(%d+)%s+(%w+)%s+(%d+)”
local monthName, TZName
monthName, xday, xhour, xminute, xseconds, TZName, xyear = string.match(dateString,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 = string.match(dateString,pattern)
convertedTimestamp = os.time({year = xyear, month = xmonth,
day = xday, hour = xhour, min = xminute, sec = xseconds})
if xoffsetHour then
offset = xoffsethour * 60 + xoffsetmin
if xoffset == “-” then
offset = offset * -1
end
end
end
return convertedTimestamp + offset
end[/lua]