Skip to main content

The Star Trek stardate for a better UNIX timestamp

A large body of software will break in unusual ways on January 19, 2038. This is known as the UNIX 32-bit timestamp bug. However, UNIX-style timestamps are used in all OSes, so it is a global phenomenon and a poorly designed software defect. 64-bit timestamps merely extend the problems presented by 32-bit timestamps to identify what day it is (i.e. what the end-user actually cares about). Perhaps there is a better timestamp we should have been using all along: Star Trek stardates.

Formal representations:

32-bit: 1 sign bit + 14 bit "day" + 17 bit percentage
64-bit: 1 sign bit + 31 bit "day" + 32 bit percentage

If we were using Star Trek-style stardates for date/time storage, our timestamps would have better precision and the upcoming 32-bit software problems would have happened early 2014 instead of waiting until 2038 for the breakages to happen. That is, force the people who created the problem to clean up their mess instead of letting them retire and have an opportunity to die off.

As I write this post on Earth SD 17345, I can only wonder what would have happened to our lowly timestamp if we had gone this route. The math surrounding dates would be simpler as the part of the day wouldn't be mixed into the actual day. That is, bit slicing is easier on a CPU than all of the modulus and division that goes on. Comparing dates and times would also be simplified. We would have increased sub-second precision within 64-bit stardates with a storage capability of around 49,710 ticks per second - compared to only 1.5 ticks per second with 32-bit stardates.

Also, why should the Pope dictate what the world's calendar looks like? The Catholic Popes gloriously failed by skipping entire days AFTER they realized that they had made serious calculation errors, they tossed in "leap year" rules which is a disaster in its own right, and more recently caused people to invent the leap second to maintain the status quo. It's a mess created by the Catholic church that needs to be excommunicated. Stardates are much more calendar-agnostic: How many complete rotations has the planet made? This approach also helps to account for rotational speed changes of the planet, correctly deals with Daylight Stupid Time (DST), readily converts to any ancient calendar format for those who need that crutch, and, most importantly, starts to prepare everyone to leave this dying planet to explore the universe.

Comments