dannyman.toldme.com


Technical, Technology

2013-02-27, Indeed!

Okay, I just have to say, Amen, XKCD and ISO!

The correct way to write dates is: 2013-02-27 ...

If you are naming files on a computer, please use this format. The beauty is that if you list files in “alphabetical order” then these dates get listed in chronological order, because as far as a computer is concerned, the “0” comes before “1” and so forth. (And a year is more significant than a month is more significant than a day of the month . . .)

It is important to have that leading zero! Why? Because we have more than 10 months! Allow me to demonstrate:

0-11:32 djh@noneedto ~$ (echo "2013-02-27" && echo "2013-12-27") | sort
2013-02-27
2013-12-27
0-11:32 djh@noneedto ~$ (echo "2013-2-27" && echo "2013-12-27") | sort
2013-12-27
2013-2-27

If you are interacting with strftime() then what you want to remember is %F!

0-11:38 djh@noneedto ~$ date +%Y-%m-%d
2013-02-27
0-11:38 djh@noneedto ~$ date +%F
2013-02-27
0-11:38 djh@noneedto ~$ date +%Y%m%d%H%M # I sometimes use this for file timestamps but dont tell Randall Monroe
201302271138

For my photographs, I have a directory hierarchy of %Y/%m-%B:

0-11:43 djh@noneedto Photographs$ find . -type d | sort | tail
./2012/08-August/Costa_Rica/Santa_Teresa
./2012/08-August/Costa_Rica/Ziplines
./2012/09-September
./2012/09-September/Sonogram
./2012/10-October
./2012/11-November
./2012/12-December
./2013
./2013/01-January
./2013/02-February

This gives me the human convenience of seeing the month name on my folders, but the computer sorts those folders in chronological order.

Read More

Next:
Previous:
Categories: Technical, Technology

Discover more from dannyman.toldme.com

Subscribe now to keep reading and get access to the full archive.

Continue reading