pmotschmann / Evolve

An incremental game about evolving a civilization
Mozilla Public License 2.0
824 stars 354 forks source link

Format date as fixed-length string when exporting save to file #1002

Closed fredden closed 9 months ago

fredden commented 9 months ago

I have been periodically taking backups of my game state using the "Save as File" feature in the settings. Today I had cause to use these. I loaded in the last file in the directory where I've been storing these, and was confused to see that this was actually an older game than I remember saving last. Upon review, I had loaded a game from near the end of September, not a week or so ago (November). This was because I went to the last file in the list, when the files were sorted in alphabetic/lexicographical order - that's to say that "evolve-2023-9-..." was sorted after "evolve-2023-11...". I've now worked this out and renamed all the files to have a consistent length to avoid this situation in future.

This pull request changes the format so that numbers less than 10 are padded with a leading zero in the filename suggested by the game. The old format was evolve-Y-M-D-H-M.txt the new format is evolve-YYYY-MM-DD-HH-MM.txt.

Here's an example filename that the game produced earlier this year: evolve-2023-8-3-16-8.txt. This pull request would instead produce this filename for the same date/time: evolve-2023-08-03-16-08.txt