Problem: I need to name log files in such a way that the file name is unambiguous to humans.
My initial solution was to go from largest to smallest unit with zero padding each unit...
- Y - 4 digit year (2019-)
- M - 2 digit month (01-12)
- D - 2 digit day (01-31)
- h - 2 digit hour (00-23)
- m - 2 digit minutes (00-59)
- s - 2 digit seconds (00-59)
- u - 4 digit milliseconds (0000-9999)
Log files should always sort in the correct order (the larger the file number the later the time)
I decided to add a few characters to make the name more human readable...
The actual time the log was written can be extracted using the rules above...
Ambiguity arises, however, when the hours are less than
13 since the hour hand of a clock can say
12 twice a day.
For example, the following future filename of...
could equally be assumed as written "super early on Valentine's Day" or "around lunch time on Valentine's Day"
Is there a way to name the log file so it's impossible to assume the wrong timestamp?
(the shorter the filename the better but you can assume no limit to the length of the filename)
All I can think of is this but maybe someone else has a more concise solution...