The Year 2038 Problem
The year 2038 Problem is the Unix 32-bit time format causing an integer overflow due to running out of available binary digits and instead gets stored as a negative number – This causes the date 19th January 2038 to become the date 13th December 1901.
Okay… phew. Now that’s over let’s look into this in layman’s terms…
Issues with date and time in computing are nothing new. I’m sure everyone, to some degree, remembers the fears of Y2K and the whole “planes will fall from the sky and we’re all going to die” journalism which just sort of vanished and was swept under the rug as time went on.
The problem of Y2K was based around the millennium and the changeover of dates from 99 to 00. Dates were previously stored in 2-digit fashion as opposed to 4-digit YYYY format which led many Computer Scientists to speculate how systems would behave as software could potentially interpret 00 as 1900 and not the correct 2000.
Thankfully, in the end, huge investment by the UK Government put towards research and testing ensured that the millennium changeover caused little if no major problems.
So Why Should We Care About This 2038 Problem?
Flashback to 1970 when the first early engineers of Unix were developing Unix, they needed a way of recording time, so Unix systems could schedule tasks and processes to run in the future and keep track of how long the systems have been running. They needed something pure with no human intervention of time zones/minutes/hours and so because of this, Epoch Time was born. Epoch is just a ticking clock which contains the total number of seconds which have passed since the 1st January 1970, and it’s still hugely used today.
Some people may remember the infamous iPhone bug in which setting your Apple devices date back to 1st January 1970 caused the device to brick and become unusable. This was because the phone tried to preform battery refreshes and run checks which were in the past (pre-1st January 1970) so no data could be returned, the iPhone didn’t know how to interpret it and so it kicked the bucket.
The Technical Bits
Much like the iPhone bug, the 2038 problem is also based around UNIX Epoch time. On the 19th January 2038, this ticking clock will become too large to be stored in a 32-bit integer, so it will overflow. Overflowing occurs when the binary is too large for its container, so it wraps around and forms a negative value which means we will go “back in time” instead of progressing to the future.
Here we see the integer overflow in action. The top row of data is the represented binary digit, the decimal is the integer version of the binary value (in other words the number of seconds since 1970), the top date is what time will be recorded as in Epoch time, and finally, the bottom date is the actual date/time.
But What Does This Mean?
Well err…. We’re not quite sure. There isn’t one set in stone solution to fix this problem and it’s not just as easy as editing the time_tdata type to include more digits and therefore more seconds for the ticking clock to grow. If we changed to a 64-bit representation of the Epoch time then this would cause code compatibility issues with current 32-bit hardware and if we changed to an unsigned 32bit data type then this could potentially work but it would only give us enough seconds to last until 2106 – yeah okay I know, seconds is beginning to not look like a word anymore.
But Do You Think Anything Bad Will Happen?
My short answer is no. My long answer is nooooooooooooooooooooooooooooooooooooooooooo.
Nah I’m only joking. I don’t think anything will be majorly affected, much like the Y2K situation we briefly looked at earlier, I believe most stuff will go unaffected. In the next 20 years, I expect most 32-bit systems to be phased out – we’re already looking at this rapidly taking place in 2018 nevermind in two decades time. The biggest threat 2038 has is in vehicles, particularly cars and aircraft. Anti-lock Braking Systems (ABS), Traction Control (TCS) and GPS receivers all rely heavily on 32bit systems – but again just like before, newer models of cars are coming out all the time and manufacturers are phasing out the old systems and innovating with the newer 64-bit counterparts.
There is also the Year 10,000 Problem… but eh we’ll let our great great great great great great great great….
…. great great great great grandkids sort that one out.