Playdate.file.modtime() not returning modification time correctly

Hi! This function probably doesn't get a lot of use because I couldn't find anything about it anywhere yet, but I ran into 2 problems when using file.modtime()

  • On device, writing to a file (with kFileWrite) does not update its modification time, and modtime seems to return the creation time instead. I'm not sure if this is maybe a limitation of the filesystem, but in that case the docs are a bit misleading.
  • It seems to return the local time on the simulator (Mac), but GMT time on the device. I'd assume the device is correct one, although the docs also don't actually mention which time(zone) should be returned.

(SDK 2.7.4)

I know you folks are working on a lot of stuff at the moment, and this one definitely falls into the mildly-annoying-but-not-completely-blocking-me-either severity. Still, wanted to post it here for posterity at least :slight_smile:


Temporary workaround
In case anyone else runs into this, you can work around the first issue by calling file.delete() before writing. For the second issue I simply check isSimulator to determine how to interpret the time, e.g.:

playdate.epochFromModtime = playdate.isSimulator
    and playdate.epochFromTime
     or playdate.epochFromGMTTime
3 Likes