Tuesday, August 28, 2018

A Short Rant About Dates in Filenames

If you are going to use a date in your filename, use YYYY-MM-DD (with or without dashes). Any other date system is wrong. Yes, that's right. If you use a different date system in your file names you are wrong.

Why?

Because YYYY-MM-DD (not YY-M-D or YYYY-DD-MM or, god forbid, MM-DD-YYYY or M-D-YY) sorts chronologically. Watch what happens when I have three files with dates, we'll call them

2018-11-28.File3.docx, 2018-06-17.File2.docx, and 2017-12-08.File1.docx

If I sort ascending by file name I get:

2017-12-08.File1.docx
2018-06-17.File2.docx
2018-11-28.File3.docx

See? Nice, chronological order.

If I use a different date system the order if fucked up, thus defeating the purpose of using the fucking date.

I will demonstrate with two variants - non-two-digit Month/Day and the standard US format of MM-DD-YYYY

Non-Two-Digit Month/Day sorted ascending file name

2017-12-7.File1.docx
2018-11-28.File3.docx
2018-6-17.File2.docx

See? 1 comes before 6, so without the leading "0" the "11" comes before the "6" in "alphabetical order" and that is not chronological order. Thus, it's wrong.

Now, let's see the travesty of MM-DD-YYYY

06-17-2018.File2.docx
11-28-2018.File3.docx
12-07-2017.File1.docx

Should we even make an attempt at M-D-YYYY?!

11-28.2018.File3.docx
12-07-2017.File1.docx
6-17-2018.File2.docx

How the fuck can anyone find what they are looking for in that garbage naming convention!?

Ok. End of rant. STOP WITH THE AWFUL DATE FORMATS PEOPLE!!!!

ISO 8601 Data elements and interchange formats – Information interchange – Representation of dates and times