I’ve got a few apps which check the current time and date to decide where the user is within a schedule and what the user can do.
I’m scratching my head a little as to how to go about testing these apps. I could fool around with the system clock, but that’ll mess up all the timers, calendars and scripts running on my machine. For now I’ve settled to hacking os.date and os.time like so:
[lua]
local offset=60*60*9 – in seconds (i.e. 9 hours forward)
local oldTime=os.time
function os.time(t)
return oldTime(t)+(t and 0 or offset)
end
local oldDate=os.date
function os.date(f)
local t=oldDate("*t")
return oldDate(f,os.time(t)+offset)
end
[/lua]
It’s a bit makeshift and no doubt will break for other people, but seems to have worked for my last project. I was wondering what approaches other people take to this? I guess the ideal thing would be to run Corona in a VM and shift the time within that.