8 ms·
The article is missing one of the best features of iso 8601: it‘s string form is naturally sortable. You don‘t need any specific logic for sorting, so e.g. your
by tpetry 6y ago
The article is missing one of the best features of iso 8601: it‘s string form is naturally sortable. You don‘t need any specific logic for sorting, so e.g. your filesystem will automatically sort files correctly if you prefix them with a iso 8601 date.
- Someone 6y agoFTA: “The elements are always padded to the maximum number of digits. This not only makes all of the dates look equally nice, but also, coupled with other quirks of this format, allows the files with the date in the name to be sorted just by the filename.”
- m12k 6y agoWhich is a side effect of being consistent with the way we write all other numbers, with the value represented by each digit declining as we go left to right.
- jeff-davis 6y agoLexicographic sorting does not work for numbers of different lengths, e.g. "100" and "9".
- pwg 6y agoIt does if you zero fill the shorter number to an equal number of digits: "100", "009".
- koolba 6y agoThere's a special place in hell for people that using variable length representations for time units that are meant to be consumed by machines. I think it's across the hall from the room for people who configure servers for anything besides UTC.
- JdeBP 6y agoIs their punishment to be forced to parse "009" with the C language's strtoul() library function for all eternity? (-:
- boring_twenties 6y agoWhat's the problem with strtoul? Just make sure to pass 10 as the third parameter, not 0.
- mywittyname 6y agoMaybe the punishment in hell should be to RTFM for the rest of eternity.
- boring_twenties 6y agoSorry, what? It's not like it's a default parameter, you would have to explicitly pass zero if you want the "guess base based on prefix" behavior.
- Leherenn 6y agoError handling is pretty horrible. And also it happily accepts negative values.
- btilly 6y agoWhere do you put the people who think that we should inflict leap seconds on UTC?
- sixothree 6y agoOn Windows Explorer it does. Not sure why other systems and apps have not adopted this.
- account42 6y agoThey have. There are even different variants of human/version sort. They are of course not as straight forward as a simple lexicographical sort so not everything is going to implement one.
- l8again 6y agoEven though it mentions this in the context of filenames being sortable, I agree that this should have been a bullet point of its own.
- justsomeuser 6y agoAlso every language has a tag for that format (.toISOString()), where as the other formats might require entering your own printf spell
- Markoff 6y agothat's reason I switched to ISO 8601 in my folders structure decades ago, obviously can't use it in regular documents/communication in Europe there used to be similar problem with alphabet (folder) sorting though, where Windows used to sort letter CH which goes after H in alphabet right within C as if CH didn't exist, but I think they sorted it in recent years, though I use English Windows and still have this issue, it's quite easy for sorting actually since H never follows C in Slovak or Czech language and when they are together they always make letter CH, so it should be easy to fix for sorting file/folder names orally we use 12 hours time format even in most of the Europe, we just use in digital watch 24hr format
- bonzini 6y agoEnglish Windows applies English sorting rules, whereby CH is not a separate letter. It is not easy at all, different languages have different rules, including multiple passes over the input (e.g. the first for letters and the second for accents), even some of them left-to-right and some right-to-left.
- eCa 6y ago> obviously can't use it in regular documents/communication in Europe What I do when travelling in Europe[1] is to un-ambuigify the date by replacing the month number with the English month abbreviation: 2021-feb-26. It's non-standard but can't reasonably be misunderstood by a human. [1] I'm from a European country where the ISO 8601 way of writing dates is common, and more specifically neither the American nor "European" formats are ever used.
- p_l 6y agoIf document didn't have specified time format, I never had issues using YYYY-mm-dd from ISO 8601. And the ones that had specified time format were upfront about expected format, so... Would be interested where anyone encountered issues with ISO8601 dates
- Viliam1234 6y ago> H never follows C in Slovak or Czech language "viachodinový" (multihour), "viachlavý" (multiheaded)... in Slovak. Not sure if there are examples in Czech. Essentially, in Slovak it is impossible to implement algorithmical alphabetical sorting without understanding the language, to determine whether "ch" appears on the word stem boundary. But yeah, you can sort 99.99% of words by assuming it does not... and maybe increase it to 99.9999% by making an exception for words starting with "viac-".
- andy-x 6y agoOnly true if you ignore timezones and DST (which most people do because it is unholy mess) or stick to UTC.
- mywittyname 6y agoYou don't need to stick to UTC, you just need to stick to a single timezone. Which is something that is generally true. UTC just happens to be a good natural choice for eliminating timezones, but I've seen companies chose another tz as their standard.
- skissane 6y ago> UTC just happens to be a good natural choice for eliminating timezones, but I've seen companies chose another tz as their standard. If you are developing software purely for internal use, that might be okay. But I think it is bad idea if you are developing software for customers, including cloud-based services. There is a good chance at some point you are going to expose your internal timezone to the customer somehow, even by accident. If a customer in another country gets told something like "process X always happens at midnight UTC, and we can't change it", they'll generally be more accepting of that than if you say "process X always happens at midnight at our headquarters timezone, and we can't change it". The second makes you sound like you maybe don't take globalisation completely seriously. Even developing software purely for internal use, your headquarters timezone may change. Maybe the company gets acquired. Maybe it just decides to move to a lower cost or more business-friendly location (e.g. Oracle's recent relocation from California to Texas). A lot of stuff is going to stick with the old headquarters timezone because changing it is just too hard. But new stuff people may well choose the new headquarters timezone instead. Now you have two standard timezones to deal with! That's why: just leave everything as UTC internally. Convert to/from user's preferred time zone at time of display and data entry. That works for almost everything, except for applications which need to schedule meetings, work rosters, class timetables, etc. For those kinds of applications, the application needs to actually save the timezone with the data, and support different records belong to different timezones.
- shpx 6y ago
- simonlc 6y agoMost forms are sortable, though dates with a timezone specified are not sortable.
- 908B64B197 6y agoThe standard American date format (MM/dd/yyyy) also somewhat has this property for a limited number of use cases. Sorting within a single year will work, sorting multiple years will place the same date adjacent to each other so it makes them easy to compare if you are printing out let's say sales data.
- emergie 6y agoAmericans using cal/foot/elbow/galon system of measurements is quirky, but bearable. AM/PM thing is silly, but bearable. Malformed MM[/-.]dd[/-.]yyyy date format is one of the most confusing thing I have ever encountered and it generates serious problems.
- emj 6y ago> it generates serious problems I would say that by just existing it create serious problems. You can never be sure if a date if day/month or month/day, this was especially bad from year 01 to 12. During those twelve years I was a date zealot "there can be only ISO 8601".
- petee 6y agoI think it makes sense only in the fact that we write it how we say it out loud - "February 26th, 2021." It is just another convention, albeit inconvenient for computers. I doubt the british way of saying "26th of February" was done intentionally to aid sorting...
- sixothree 6y ago> it generates serious problems So do time zones. So do leap seconds. So does the speed of light. I guess deal with it. None of what you argued negates the post you replied to. He is right after all. Dates within the year are sortable by pretty much any system. But most of all the format makes ISO 8601 quite easy for Americans to wrap their head around. So maybe stop complaining and look at 8601 as a possible solution to what you consider confusing and problematic.
- deleted 6y ago[deleted]
- marzell 6y agoThis is my primary reason for advocating yyyy-mm-dd (regardless of including hh:mm:ss) in my work environment. I always feel it's very simple to explain things like "you can sort by name and it's automatically sorted by date" and it's just unbelievable the amount of pushback I get. This coming from users having trouble finding files from a certain time period, as their timestamps might be different due to copying/modifying. Also easy to convert to INT (i.e. yyyymmdd/20210226) for use as a partition key or FK for a date dimension.
- sixothree 6y agoSame here. Even when it's just a folder with a document that has multiple revisions. And especially around this time of year (near the end/beginning of the year).
- hilbert42 6y ago"your filesystem will automatically sort files correctly if you prefix them with a iso 8601 date." It's the default date format on my PCs, I've used it for decades. I find it hard to understand why eveyone doesn't use it. Also, if you work for the UN, it's the default date format.
- geonic 6y agoThat’s why I use it exclusively to prefix my file names. It’s sortable, easy to parse visually and always has the same length.
- justaj 6y agoExcept on Android, since you may not have files with the ":" characters in it.