os.date, add/subtract 1 day

I have the attached “datepicker” which looks this way because of space constraints.

The arrow buttons should increase and decrease the date, respectively.

I must be blind or tired because I can’t seems to find how to do this (without handling days-of-months and leap-years myself, that is). 

Is that what I have to do?

Edit : I found some help here, but the example function gets nils from the string match inside.

I made a simplified version, which works for strings like 2013-09-09:

function datetotime(s)     local xyear, xmonth, xday = s:match("(%d+)%-(%d+)%-(%d+)")     return os.time({year = xyear, month = xmonth, day = xday, hour = 0, min = 0, sec = 0}) end  

I made a simplified version, which works for strings like 2013-09-09:

function datetotime(s)     local xyear, xmonth, xday = s:match("(%d+)%-(%d+)%-(%d+)")     return os.time({year = xyear, month = xmonth, day = xday, hour = 0, min = 0, sec = 0}) end