Live data from Hacker News

ISO 8601: a better date format

kirby.kevinson.org

161–170 of 437 posts

Re: ISO 8601: a better date format

#161

Earlier quoted context omitted.

Format the date on the frontend using date.toLocaleDateString() and let the browsers locale do the work for you (assuming you’re in JS and on the web).

> Date().toLocaleDateString() > Uncaught TypeError: Date().toLocaleDateString is not a function That doesn't seem like a standard API call.

It is standardised and widely implemented.

https://developer.mozilla.org/docs/Web/JavaScript/Reference/...

Your code has a bug, missing constructor.

Re: ISO 8601: a better date format

#162

No one here is talking about practicality for non-software engineers which is probably 99.9% of the population. It might be fine for sorting and no one gives a shit about endianess. Common person would argue - why do they need to know the year first? Most people encounter dates in the same year, they already know we're in 2021 and it is not as important. Having to laboriously parse YYYY before getting to the most imp…

I think you have a valid point which is irrelevant to ISO 8601 however. You may be right that common dates are in the same year, but such dates would be most conveniently written without the year number at all. If you need to write the year to your date, either because it's not the current year or it's consistent with other dates with the year number, then the year number is significant and all arguments against ISO 8601 breaks down.

Re: ISO 8601: a better date format

#163
post #31

I use the 2021-02-26 format for every place that asks for a date without a clear format. All legal contracts, forms, email etc, across US and Europe. Never got any trouble for it - it seems people readily understand the format even if they may think it's a bit unusual. I wish it was the norm.

Yeah, I deal with so many different countries that it is a minefield using any other date format than RFC3339/ISO8601. I have been stung by having my birthday month and day inverted a few times when using DD/MM/YYYY format.

Re: ISO 8601: a better date format

#164

Tangentially related: I hate GNOME's approach at configuring formats. In their format settings, you have to pick a country and that determines the format of dates, time, numbers, and the unit system. Of all the countries, none of them has the sane choice for all of the fields, namely: ISO 8601 for dates and times with 24h (no AM/PM), metric system (or SI, whatever), and dot as decimal separator. You can have sane dat…

Probably those are from the locales package?

en-dk is the best one, it is Europe standard english which I think fits all your requirements for Saneland.

Re: ISO 8601: a better date format

#165

The real advantage is that Azure and AWS and every other US-centric cloud service insists on showing me that something happened on the 3/11/2021. It's a wild guess to figure out if that is the 11th of March or the 3rd of November. Unless there's also another date with a number higher than 12 in it, there is no way to tell. None. None whatsoever. For US staff with US regional settings, it's always obvious which date i…

It's more obnoxious to be lectured by people who think "June 3rd, 2021" isn't shorthand for "AD 2021 June 3rd", which is proper logical and sorting order.

You're saying that 06-03-2021 is shorthand for 2021-06-03 and are confused why people don't get that?

Re: ISO 8601: a better date format

#166
post #145

The real advantage is that Azure and AWS and every other US-centric cloud service insists on showing me that something happened on the 3/11/2021. It's a wild guess to figure out if that is the 11th of March or the 3rd of November. Unless there's also another date with a number higher than 12 in it, there is no way to tell. None. None whatsoever. For US staff with US regional settings, it's always obvious which date i…

M/D/Y is a bit like the German way of reading numbers. 328 become three hundred, eight and twenty. Terrible

How about french? 99 is four twenties nineteen, 79 is sixty nineteen. Languages are fun and fascinating.

Re: ISO 8601: a better date format

#167

It is a good format for sorting, but misses the point of use. As humans, we want to read the most significant data to our use case first. The author confuses value to the reader with magnitute . In normal numbers, they happen to be the same thing. In most cases, we want to discern between days first, them months, then years. If you look at a list of dates: 2021-01-01 2021-01-02 2021-01-03 2021-01-04 You're just going…

> In most cases, we want to discern between days first, them months, then years.

That really, really depends on particulars on your life. While I strongly dislike the US format of putting the month first, the irony is, the month is the most important datum for most of the dates I read with. Year is usually obvious given particular context (it's typically either the current one, the next one, or sometimes the previous one). Days don't matter for anything that isn't in the same month. I'd go as far as saying that months are typically the most important for most people in XXI century, then days, then years.

But that's no problem for punctuated date formats in general. People don't read things linearly at letter level, they deconstruct tokens in a random-access way. Separators like - or / help clearly identify which part is which (compare how easy it is to read 03/01/2021 with 03012021), and there's no extra cost associated with reading off the part in the middle.

The benefits of YYYY-MM-DD notation on top of the above are:

- With all terms being fully expanded, dates line up vertically as well, which helps when dealing with stacks of documents or tabular data.

- Being ordered by magnitude like normal numbers provides a Schelling point for interpretation[0]. That is, when a random person who wasn't exposed to much computing or internationalization before sees 2021-01-03, they will automatically assume that 01 must be the month, because writing YYYY-DD-MM would be dumb and inconsistent with how numbers are written in general.

Yes, both of these apply to DD/MM/YYYY, but, YYYY-MM-DD also gets you sane lexicographic sorting, which the UK/European format doesn't. It's super useful feature not just when dealing with computers, but also when perusing any kind of date index. ISO 8601 dates work much like words in a dictionary, you can binary-search through them.

--

[0] - https://en.wikipedia.org/wiki/Focal_point_(game_theory)

Re: ISO 8601: a better date format

#168
post #48

Earlier quoted context omitted.

China and Japan have Sunday as the first day since the 4th and 8th century respectively: http://chartsbin.com/view/41671 . So presumably, you come from a Europe-centric view: http://chartsbin.com/view/41671

The problem is that the US directs how much of my software is built.

Don't you just use localization features of your API for this?

I'm an iOS developer, and whenever I print dates, I just ask the system to print it, according to the system its locale.

Re: ISO 8601: a better date format

#169
post #115
post #48

Earlier quoted context omitted.

China and Japan have Sunday as the first day since the 4th and 8th century respectively: http://chartsbin.com/view/41671 . So presumably, you come from a Europe-centric view: http://chartsbin.com/view/41671

historically europe also started the week on sunday as per christian tradition. i too grew up with the idea that the week starts on sunday. this change to starting the week on monday is therefore a recent development. same in china btw. days in china are numbered. monday is number 1, and sunday is 7. so while people may have the idea that the week starts on sunday (i don't know) the day numbering suggests that it act…

> sunday is 7

My understanding is that all days except Sunday "week-day" (星期日) are numbered. Monday is (星期一) "week-one". So there is still some room for ambiguity left if you allow for counting from 0.

Re: ISO 8601: a better date format

#170

Earlier quoted context omitted.

It took many decades to widely adopt UTF-8. I think that one of the reasons was that US companies did not really care about character encodings, as it's not something they have to often deal with. Even today managing multiple keyboard layouts is a pain in most operating systems, it's buggy, it does not have enough configuration options, it's not convenient. Probably because most US developers never tried to use that…

My wife recently bought by mistake a keyboard whose layout I couldn't figure out. It took me a full 5 minutes to even get to the correct place where I could configure keyboard layouts under Windows 10 settings. Then I had to choose the keyboard layout I wanted to add. This was a list in a dropdown with hundreds of options without an image of what each layout looks like so I could not check which option matched the ke…

I like the method that Mac OS uses to detect the layout of a newly connected keyboard. It brings up a dialog asking the user to press specific keys (something like "type the | character") until there is only one possible layout that would generate the observed keycodes for the characters in question.
Post reply on HN