How to display Timestamps which are unambiguous?
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...
YYYYMMDDhhmmssuuuu.log
- 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)
201912051357040042.log
I decided to add a few characters to make the name more human readable...
2019-12-05_13-57-04-0042.log
The actual time the log was written can be extracted using the rules above...
2019-12-05 13:57:04.0042
Ambiguity arises, however, when the hours are less than 13
since the hour hand of a clock can say 01
- 12
twice a day.
For example, the following future filename of...
2020-02-14_12-30-11-8675.log
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...