Let's restart counting Unix timestamp to from 2020
Old counting start date: Jan 01 1970 01:00:00 GMT+0100
New counting start date: Jan 1 2020 00:00:00 UTC+0000
Example in Dev Tools how to get the new epoch time
const newBeginning = new Date('Jan 1 2020 00:00:00 UTC+0000')
const newEpoch = Date.now() - newBeginning.getTime()
console.log('New epoch timestamp', newEpoch)
21 comments
[ 6.4 ms ] story [ 76.2 ms ] thread[Edit] Answering my own question it appears some systems have already addressed this by moving to 64 bit time [1] thus kicking the can down the road 292 billion years in both directions.
[1] - https://en.wikipedia.org/wiki/Unix_time
What’s the use case for it, where this would be a good trade off?
But for other use cases - not so great.
There's no reason you can't use a 64-bit value in a 32-bit system. Much simpler to access the 64-bit value as two 32-bit words than propose a whole new confusing and ambiguous system.
In terms of current-time coding, the only time that second hi-order word would be used is when the lo-order word overflows, and on initialisation of the 64-bit variable. And if needs must, it could even be a compiled-in value, seeing it will only change once in every 68 years.
It's not true that it's much simpler to work with two 32bit words for a date than working with simply restarted clock. Basic arithmetics cannot be used reliably so every operation must go through a library like i.e. bigint used to require. This complicates the system and the goal of having a reliable 32bit date format in the future is for simplicity.
Obviously if you move toward 64 bits, as most systems have already done, you don't have a problem.
So if you want to stick to signed 32 bits, let's instead agree to restart counting 32 bit UNIX timestamps for the new epoch at exactly Sun Feb 7 06:28:16 AM 2106 UTC.
Sure, it's not a very round number in human terms, but has the advantage of requiring significantly less implementation.
Of course you still have the same problem of knowing which epoch you are in, but that's intrinsic to the problem when you only have 32 bits.
Any system of assigning epochs needs to have some method to determine which epoch you are referring to, so that's no different no matter if the scheme starts in 2020, 1970 2040, etc. So just use the natural modulus of 2^32 if you are using signed 2^32 to represent dates. When it rolls over, you're in a new epoch.
I'm kind of trying to point out that if you have a calendar that repeats after every 2^32 seconds, and you have more than 2^32 seconds to count, your problem is that you have too small of a counter, not wherever the arbitrary start point is - changing that is silly and just adds complication.
In 99.9% cases there will be no need to keep track of the epoch just like the current computers don't look before 1970. In rare cases if its required the epoch can obviously be stored in another byte.
how so? as it happens computers handle this automatically when using a signed 32 bit integer. It's easy to implement because there is literally no extra work.
> In 99.9% cases there will be no need to keep track of the epoch just like the current computers don't look before 1970
so then why would you not suggest using unsigned 32 bits and going straight to 2106 that way?
I think you need to take some time and get comfortable with both 2s complement and modular arithmetic to understand the right trades for a solution to 2038 and why creating yet a new date standard of 2020 isn't a better idea than what's already been done and several other things that could have been. There are a lot of other gotchas and design decisions. That's why what I suggest is somewhat tongue in cheek and not a serious proposal. But it's objectively better in all criteria than starting again with 2020 (or 2000, or ...).
I leave you with: https://xkcd.com/927/