173 points · by PaulRobinson · 3y ago · 131 comments
It only takes 23 years to forget history.
I dont think this means people have forgot history, rather, I think people make tradeoffs. You trade off size/space/ease for long-term disruption. Most developers making these decisions now will be close to a 100yo in 2199. It will not be their problem, or even their childrens' problem. Possibly their grand-children's problem.
Alternatively, I could argue that the life of most systems is short enough that 80yrs is too long a horizon to worry about the problem.
We're giving people too much responsibility too young.
Lo, nobody complained about the readability because most time problems are relative to other events, rather than to a specific clock time. It’s so much easier to work out that two events occurred a few milliseconds apart when you don’t need to take segmentation (ie: ymdhms.s) into account. And using an integer obviates time zone and daylight savings corner cases. You can simply subtract two numbers and get useful information. And it’s much easier to do the math in your head and in scripts.
For those relatively rare times that you do need to know the clock time, there are CLI tools (ie, date -s) and websites galore.
Of course my use case was not everyone’s use case. But I ignored the blanket recommendation to use human readable time, and despite the naysayers, life became much easier for me and my team. I doubt that I would go back to string timestamps for any purpose.
Honestly, human time is for humans, it’s a presentation problem. Computer time is for computing.
IF you know they occurred a few milliseconds apart, integers are marginally easier.
1695029423495
1695029423502
2023-09-18T09:30:23.495Z
2023-09-18T09:30:24.502Z
But for every other case, it's much harder to discern the difference. 1695029423495
1695029483502
2023-09-18T09:30:23.495Z
2023-09-18T09:30:25.502Z
It's far easier to compare these using the commonly practice of ISO 8601.But yeah, I take your point.
Or to put it another way, they cannot be trusted to engineers to get it right every time. Let's face it, even something as simple as floating point numbers have serious issues when implemented in computer systems (so another candidate for strings quite frankly - notable that JSON is strings all the way through).
The date value should always be stored and passed around as an int — and then only transformed into a user-readable string on the client-side at render-time, only when it's necessary for a human to read it. It's the job of frontend code to take in the date as input (still as an int), detect the reader's timezone, and render accordingly.
For some systems, you may want more precision, in which case millis (or nanos) are reasonable, as long as you choose a big enough int type to hold them.
Once humanity goes from 1 planets to N planets, the whole thing will become a mess again thanks to relativity, and software engineers of the future will have to deal with figuring out how to convert an Earth timestamp to a Martian timestamp — and what it even means for two timestamps to be "equal" then.
But that's next century's problem. ;)
Your event is initially in the user's timezone (e.g. 10am 20th of June 2024 in France), if you store it as a number then you are fixing the exact second at which it will happen. However, if the timezone in question has some changes you didn't anticipate (new law voted, no more summer time), then you will either be triggering your event 1h before (e.g. 9am instead of 10am) which is probably not what your user wanted, or you'll have to recompute all your timestamps to take that change into account.
Instead, you could store rhe event with the target timezone, and let your datetime library that is up to date figure out next year.
Sometimes they are, sometimes they are not.
For example...date+time of birth. The legal date (timezone) is a significant part of this event's time.
> passed around as an int
We're talking about a CSV. CSV don't have ints.
You can use base-10 encoding of the Unix timestamp, or the ISO 8601.
I would add that a UI might prompt for a date as well, which of course would be entered using a local time input element based on the the users time zone. But that local time would immediately be converted to an int and passed to an API.
I mean, sure, serialize them as ISO8601 strings, but, no, dates are fundamentally not strings, and that shouldn't be their basic internal representation in most sane systems.
In CSV, though, everything is strings. But the question there is what string format.
the real solution is to store 64-bit seconds (or perhaps 96-bit microseconds, if you need precision) since some epoch, like jan 1st 1970. it's a simple integer that monotonically increases with a defined starting point. you can't get any more simple or reliable than that.
the unix time stamp was a wonderful solution, they just chose to use too few bits for how long their system would end up living. 64-bit integer seconds will last something like 42x the age of the universe, so that ought to cover things.
Event specification is a very complex and politically entwined idea. This involves not just a frame of reference for the time, but also a location within which that time should make sense. Otherwise it is impossible to derive the correct rule-set for evaluating the human interpreted value of that moment.
An alternative which might make sense is to force people to specify which ruleset they desire with the offset value within said ruleset.
Sadly, my preferred representation of time isn't expressed in either of the popular standards (RFC 3339 or ISO-8601). https://ijmacd.github.io/rfc3339-iso8601/
RFC 3339 gets closet to my preference with: 2023-09-17 23:51:41Z
However these are examples of what I'd prefer to see:
* 2023-09-17 23:51:41 Z UTC
* 2023-09-17 16:51:41 PST8PDT USA/WA/Seattle
* 2023-09-17 16:51:41 PST8PDT Canada/British Columbia/Vancouver
Note: At the moment Vancouver BC and Seattle WA happen to observe the same time offset but are in different political locales with different DST shift times. I'm not sure if it's still correct to call either timezone PST8PDT... that may imply the USA/CA/Los Angeles.Time would be expressed numerically 'large endian first' format, with zero or one punctuation element between units, preferably expressed with individual units matching the most correct (easiest for a human to read what they expect) value at a glance. This means - (or no separation) for dates, and : (or no separation) for HMS. (Space) or _ (Underscore) are preferable for between units. The timezone 'name' follows the smallest unit of time, which is itself followed by the reference city. Implicitly events in the past were accurate at the time they were encoded, while events in the future might need re-validation and conversion if the rules have changed. Though it would be even smarter for the human important metadata (a string, probably) of recognizing the future event(s) be stored rather than a precise moment which may be incorrect.
It isn't. See leap seconds.
Using a string would allow you to distinguish UTC from UT1. Only UT1 is monotonic.
If it's in the past, no
Logically, reaching for a justification, an explanation, sure, it's reasonable that the MSB flips halfway around, but again it differs from the analog clock reading conventions.
v2 (+/v2.html) which he posted on another thread, does make it clearer
https://retr0.id/stuff/2038/v2.html
Other thread of his blog domain
https://www.da.vidbuchanan.co.uk/blog/unix-clock.html
https://news.ycombinator.com/item?id=37492371
The color separation is also a bit large, mainly 2-3 and 3-4, while 1-2 are similar but distinct.
function prompt_epoch() {
printf -v COMMA_EPOCH "%'d" ${EPOCHSECONDS}
p10k segment -f 66 -t ${COMMA_EPOCH}
}
EPOCHSECONDS relies on `zmodload zsh/datetime`. printf -v creates a variable rather than output text. p10k segment is just a function that powerlevel10k uses, you don't have to use it. COMMA_EPOCH is just the current Unix time separated by commas every 3 digits.If you wanted your own countdown, you could easily do `2147483647 - EPOCHSECONDS` and display that time instead.
EDIT: and if you want to mimic that oh-so-cool clock, you could do:
printf '%x\n' $EPOCHSECONDS
or assign that to a variable with printf -v, then split the string into pairs. Mimicking the colours of the clock would be fairly trivial too.Is there any advantage to using that module instead of invoking
date +%s
I use zsh but I don’t have any addons installed or anything. So for me it is less work to call date +%s insteadWelcome to workstation - Today is Sunday, September 17th 2023
There have been 53 years and 272 days in the unix epoch!
There are 14 years and 127 days until the 32-bit time apocalypse
Prepare yourself...people wore binary wristwatches because they wanted to be seen wearing binary wristwatches, that's it.
to me, activities like this are the absolute epitome of waste and vanity. (both are bad, if I'm not being clear, here.)
but, I also think that it's perfectly ok for people to like whatever they want to like, as long as it doesn't hurt anyone, so I guess it's like "I don't like what you're saying, but you absolutely have the right to say it."
You're right that it's wasteful—those watches are mostly e-waste at this point. But so are all the electronics we've bought in the past 20 years. I'm typing on future e-waste right now!
I'm not even sure if in hindsight the wrong decision was made.
Unix time is 32 bits, so I guess Unix time was invented a bit later, but around 1970, when Unix was written, RAM cost around $700k/megabyte, or, ballpark, $1/byte (https://jcmit.net/memoryprice.htm)
Even if you had infinite memory, you couldn’t use much of it in your computer. The PDP-7 that Unix started life on topped out at 144kB, the PDP-11 that it was soon ported to at 288kB (64k 36-bit words), and many installs wouldn’t have that.
~Not enough people in 1985, I guess. They seem more concerned with leap years than anything. https://groups.google.com/g/net.bugs/c/ZGlqGwNaq3I
But at least Jeff bezos is putting his fortune into an immortal clock in the desert (I'm being sarcastic but the desert clock is actually real and supposedly a gift to future generations as if measuring time wasn't a problem that stone-age civilizations all over the world were able to solve independently).
https://en.m.wikipedia.org/wiki/Time_formatting_and_storage_...
https://en.wikipedia.org/wiki/Variable-length_quantity
This way the counter can scale up to any number of bits.
A 64-bit signed Unix time fixes this for 25x longer than the remaining lifetime of the sun.
AFAIK, most systems with absolute nanosecond precision use two 64-bit ints.
i’d just pick a huge number and move on.
I find it hard to believe we will ever have femtoseconds-resolution timers or ever even care what femtosecond an event happened at. But even if we do, incidentally, 128 bits is still fine. i128 femtoseconds will overflow in approximately the year 1000000000000000000000000.
So, I don’t think there’s any practically useful time unit for which we need variable length integers and can’t just use i128.
I’d have thought mainframe dates were mostly binary coded decimal in EBCDIC and already futureproofed during the y2k mania.
https://arstechnica.com/information-technology/2023/08/ibms-...
So it does not save you much time.
But cool clock, really love it!
Chiyo Miyako was born on 1901-May-02
Plus bonus points for, when mentioning how 64 bit ints are the solution here:
FF FF FF FF (u32)
=
00 00 00 00 FF FF FF FF (u64)
makes it pretty clear what the trade off in memory usage is vs range gained.