5 ms·
ISO8601 strings are sortable and are not numbers.
by wolf550e 5y ago
ISO8601 strings are sortable and are not numbers.
- 88913527 5y agoCharacter sorting isn't a natural law. The fact that "A" comes before "Z" is historical; it's 'always been done that way'-- at least since the Phoenicians. https://en.wikipedia.org/wiki/History_of_the_alphabet#Descendants_of_the_Aramaic_abjad https://en.wikipedia.org/wiki/History_of_the_alphabet#Descen...
- tuwtuwtuwtuw 5y agoNo they aren't. 10000 can be a valid year according to ISO8601, but sorted as a string it would come before year 2000, which would obviously be incorrect. Here's from the ISO: > 3.5 Expansion By mutual agreement of the partners in information interchange, it is permitted to expand the component identifying the calendar year, which is otherwise limited to four digits. This enables reference to dates and times in calendar years outside the range supported by complete representations, i.e. before the start of the year [0000] or after the end of the year [9999].
- otterley 5y agoSounds like a problem we don’t have to worry about for another 8,000 years or so.
- SAI_Peregrinus 5y agoWhich comes first, "2021-W52-6T15:10.4" or "20220101T151115.1-05"? Lexicographic sort between those two ISO-8601 date/time strings will get it wrong. Did you mistake ISO-8601 for RFC-3339? Even there lexicographic sorting isn't guaranteed, since you can have a pure date or a pure time or a date-time combined, and there's a choice between "T" and " " to separate dates from times in a date-time but it's much more likely to work than with ISO-8601.