by mg · 1y ago · 0 comments
I consider it the "Markdown for time". It is human-friendly and computer-friendly at the same time. It is supported by many languages and databases. It is so elegant and common that even though it is not part of a standard, LLMs started to use it when writing answers:
Me: SQLite: Add 1 day and 3 hours to a date.
Perplexity: SELECT DATETIME('2025-09-07 07:51:00', '+1 day', '+3 hours');
Things like opening hours or appointment times are always local time, and even if Apple disagrees I very strongly believe that alarm clocks should use local time as well.
Even your example of alarms is not obvious. If you set a timer, or a daily alarm to wake up by, then yes. But if you set an alarm for some event, like sunrise for example, then you would need a zone.
We may not know the location when we write down a datetime. It could be "wherever I may be at the time".
Even if we do know the location, we cannot know for sure what point in time a future local time refers to because locations can change timezones.
>Even your example of alarms is not obvious. If you set a timer, or a daily alarm to wake up by, then yes. But if you set an alarm for some event, like sunrise for example, then you would need a zone.
That's absolutely right. We need to be able to store points in time and we need to be able to store local times relative to locations that are yet to be determined and relative to as yet unknown timezones. The two concepts cannot be merged.
You need a timezone as well.
If I set my alarm clock to 7am, I want it to always wake me at 7am local time regardless of where I happen to be on that day.
If I make an appointment for 7 Sep 2026 at 3pm I'm going to turn up at whatever time counts as 3pm on that date. The government might scrap DST, so the exact point in time is currently unknown.
Many uses of local time cannot be expressed correctly if you are forced to specify a timezone.
This type of date/time is also very useful to store in a computer.
There is even more fun corner cases. Say you live at border of timezone. First have a meeting at 12:00 for 45 minutes in one zone, then move westward and now have an other meeting at 12:00. How do you mark these in calendar? Communicate them? Make historical log?
It's potentially a local time, potentially not. It's unspecified and that will cause trouble.
If you want to model "stores open at 8:30am, worldwide" then there are data types for that "time only". They are not "date and time".
When does that happen.
GNU date defaults to EDT, but adding the local time zone name can give the other time:
date --utc --date='TZ="America/New_York" 2025-11-02 01:30:00'
Sun 02 Nov 2025 05:30:00 UTC
(Which is 01:30 EDT)
date --utc --date='TZ="America/New_York" 2025-11-02 01:30:00 EST'
Sun 02 Nov 2025 06:30:00
although for London it defaults to GMT: date --utc --date='TZ="Etc/London" 2025-10-26 01:30:00'
Sun 26 Oct 2025 01:30:00 UTC
date --utc --date='TZ="Etc/London" 2025-10-26 01:30:00 BST'
Sun 26 Oct 2025 00:30:00 BST
It throws an error the other way: date --utc --date='TZ="Europe/London" 2025-03-30 01:30:00'
date: invalid date ‘TZ="Europe/London" 2025-03-30 01:30:00’A datetime can be seen as a number written in a positional notation, just with varying base: divmod by 60, 60, 24, 12. When you pick a normal decimal / hex / binary number, you expect that the digits in it come in the order of magnitude changing: thousands, hundreds, tens, ones. Mixing them would feel crazy. By the same token, formats like dd-mm-yyyy HH:MM or mm-dd-yyyy are crazy; sadly they are traditional.
Is there a timezoned version of this that is standardized?
2025-09-07 10:57:00Z+2 would be CEST for example. (+2 hours ahead).
2025-09-07 04:57:00Z-4 would be EDT (4 hours behind UTC)
Datetime + tz name: a point in time and space that is responsive to time zone changes. E.g. Our zoom meeting is on 3 Feb 2026 17:40 in Moscow time.
Local date time: a calendar date that is independent of time zones.
Instant: an exact point in time. e.g. the rocket will launch at 123456789 seconds from the Unix Epoch TAI.
Formatted string: an exact point in time rendered for the human user in their local timezone and calendar, taking into account leap seconds. E.g. The rocket will launch on 7 Ramadan 1447 AH, Saudi time.
No. It isn't a point in time, because time zone transition rules can and do change. You need an offset as well. Then you can choose which thing you want to prioritize[1] when converting it to an instant in time.
This is what RFC 9557 is for.
[1]: https://docs.rs/jiff/latest/jiff/tz/enum.OffsetConflict.html
The application knows how it stores data, so it can just use UTC or whatever it likes. One timezone for all entries.
The interface then can display it in a way the user likes.
If you specifically only care about moments in time, throwing away the input time zone might be fine.
If the application is more human centric, timezones are often very useful as humans move around but often think about time as timezone-relative. A log of your daily activities would be confusing if a past event logged as 09:16:01 suddenly showed up as 07:16:01 because you're travelling when viewing it.
At some point some application developer will introduce a bug where they're not sending utc.
Without the time zone, the wrong times will end up in the database, bad data mixed in with good. This will be a nightmare to fix.
With the time zone, I don't think this class of bugs is possible. Most application developers will wrap the time in an object that allows them to do time operations without needing to directly handle time zone in most cases.
So yes, I agree a local datetime format is necessary but not sufficient.
I'd like an en_EU definition to be added, except I went to find an official definition[1], and found the EU uses both.
Elsewhere [2] it says the use of a comma is due to "technical limitations".
I use en_GB or en_IE, but
export TIME_STYLE=long-iso
so I get ISO dates in many GNU programs like "ls".[1] https://style-guide.europa.eu/en/content/-/isg/topic?identif...
[2] https://commission.europa.eu/system/files/2023-11/styleguide... §6.10.
> It is human-friendly and computer-friendly at the same time.
It's not shell-friendly, because of the space. The shell being an interface between humans and the computer, this takes a chunk out of it being human-friendly and computer-friendly. You'll have to worry about quoting the thing, involve messing with IFS when making arrays of the things, extract both pieces out of text columns aligned with spaces, awk's NF wouldn't correspond with number of fields anymore, etc. Would make timestamps unnecessarily annoying to interact with. Better to at least make it an underscore. Still quite readable.
And not all computer-users worry even a little bit about compatibility with Windows.
It's also not that "user friendly": depending on their locale, users will usually expect for instance DD/MM/YYYY. Sorting by YYYY-MM-DD won't feel natural to them.
It's dictionary sorting.
YYYY-MM-DD hh:mm:ss seems valid ISO 8601 to me, isn't it? Neither the "T" nor the timezone are required as far as I recall.
EDIT: The site says ISO 8601-1:2019 requires a T for datetimes, and that even though previous editions allowed for no T, a space was never allowed. This is shocking news to me.
For example, what is the answer to in New York?
SELECT DATETIME('2025-03-07 23:30:00', '+1 day', '+3 hours');
If you said `2025-03-09 02:30:00`, then that would just be wrong. Because that time never appeared on clocks in New York.Programmer-friendly for debugging? Sorry No. I don't mind the extra T in between and I'd actually like to see the timezone or zulu in logs when debugging.
A counter view would be: it's half-human-half-computer inclined, but not objectively good for either.
I fail to see why it is not considered human friendly. Its more specific, a day is 24 hours, at least I much prefer it to "am/pm".