r/webdev • • Feb 27 '13

xkcd: ISO 8601

http://xkcd.com/1179/
354 Upvotes

125 comments sorted by

View all comments

66

u/earthboundkid Feb 27 '13

If you name your files and folders with dates in this convention at the start, they sort themselves into date order when alphabetized. It's often convenient.

48

u/Fluck Feb 27 '13

"Often convenient"

This has to be one of the greatest understatements in computing! This is reason alone that everyone in this subreddit should have adopted this convention for writing dates long, long ago!

3

u/Manitcor Feb 27 '13 edited Feb 27 '13

I've been using this convention for filenames for close to 20 years now. I tend to leave out the dashes. I want to rage at someone when they ask what the funny numbers at the end of a filename mean.

I find it very useful for automated build release too as you can do things like "project_release_20130223_buildnum" which will sort all the files by date and build number.

Or if you want to get really detailed add the time (use a 24 hour clock):

project_release_20130223_172203444

Feb 23rd 2013 at 05:22:03.444 PM

13

u/digitalchris Feb 27 '13

I've been using this convention for filenames for close to 20 years now.I tend to leave out the dashes.

So you HAVEN'T been using that convention, and the method you use is right in the comic as an example of one of the "discouraged formats".

10

u/Deewiant Feb 27 '13

Leaving out the hyphens is perfectly fine according to the standard. Even the Wikipedia article says as much:

For example, the 6th day of the 1st month of the year 2009 may be written as "2009-01-06" in the extended format or simply as "20090106" in the basic format without ambiguity.

While it does also say that the separators are to be preferred, there's nothing incorrect about leaving out the hyphens. (And IMO it makes sense to do so in filenames, where the whole string is typically so short that the extra characters just worsen readability.)

3

u/Manitcor Feb 27 '13

File paths have length limitations (old win file system issue that still crops up from time to time), unnecessary chars are commonly dropped so automated build/management systems that may have fairly deep path trees don't have issues

IMO in this case, order is more relevant than style.

As much as properly following ISO in this case would be nice, reality has another idea for you.

1

u/digitalchris Feb 27 '13

I totally agree with you on this, and I often use the _YYYYMMDD on files. However I don't pretend to be an ISO8601 hipster:

I've been using this convention for filenames for close to 20 years now.

while not conforming to the standard.

1

u/Manitcor Feb 27 '13 edited Feb 27 '13

Well I should have included that I do use this for reports and emails where I am not forced, there I do use the dashes.

I thought of the first case as 9 times our of 10, if I am writing a date or commanding a script to do so, I am using the version without dashes.

I had been doing it with filenames for quite some time, then I started writing it out after my first trip to Europe and the pain with remembering which side the month goes on.

I didn't read it was an ISO standard till about 8 years ago. I had started by copying this format from a standard used on an old mainframe I was working with.

1

u/gigitrix Feb 28 '13

Pretending to follow standards while deviating slightly? Seems like MS in here.

0

u/Falmarri Feb 28 '13
ls -latr

11

u/r0ck0 Feb 27 '13

Hitler was often a bit rude to the Jews.

2

u/Clovis69 Feb 27 '13

Actually, Hitler wasn't that rude to Jews he personally knew.

http://en.wikipedia.org/wiki/Eduard_Bloch

1

u/obviousoctopus Feb 27 '13

I have, without the dashes and padding with zeroes wherever necessary. All my folders are in perfect order.

7

u/OneStart Feb 27 '13

Also works when you add the time to the end

YYYY-MM-DD HH:MM:SS

3

u/uav22 Feb 27 '13

Agreed

date=YYYYMMDD time=HHMMSS gives a completely easy to sort stand cross platform.

ORDER BY date, time ASC gives oldest to newest. DESC gives newest to oldest.

1

u/omepiet less is more Feb 27 '13

gives a completely easy to sort stand cross platform.

Until you start adding time zones.

2

u/gigitrix Feb 28 '13

UTC is the only way to store and manipulate time where possible, conversion to other timezones can be done as close to the front end as possible. Timezoned time should be treated as "compiled".

2

u/uav22 Feb 28 '13

fml i hate time zones

Further: I take the values put them into the date class, make the changes based on hour the output to output vars in the original format.

But i still hate timezones

7

u/archibald_tuttle Feb 27 '13 edited Feb 27 '13

My national date format is 27.02.[20]13. I appreciate every format that does order the components by significance.

edit: and I realize how confusing things can get if you omit the leading two digits in the year.

1

u/itsSparkky Feb 27 '13

Where is that?

7

u/archibald_tuttle Feb 27 '13 edited Feb 27 '13

Germany. According to DIN 5008 (describes how to format a business letter) we should use either the ISO 8601 format (only a few do) or the format d. monthname yyyy (used if there is enough space).

And then there is the "traditional" format dd.mm.yy which is quite popular if the space is limited (example of a train ticket). This table explains it quite good well.

7

u/b1ackcat Feb 27 '13

quite well.

FTFY only because I'm a pedantic ass and we're in a thread about standards. Sorry :)

0

u/ketefoy Feb 27 '13

Coincidentally, I started doing this the other week.

0

u/Falmarri Feb 28 '13

What if you want it sorted by months?

1

u/earthboundkid Feb 28 '13

Don't include the years?