|Cartoon - Why 1970? or Dating Troubles
|Written by Mike James
|Sunday, 20 May 2012
This week's xkcd cartoon might be a problem if you have never had any difficulties with dates. However, if you have never had any difficulties with dates, this suggests that you have never had to work with dates - as dates usually mean problems.
First - what has 1970 to do with it?
The answer is Unix.
The Unix operating system was a huge advance in terms of what you could do with a small computer. Linux is the direct descendant of Unix and most other operating systems in use to day owe a great deal to Unix. As a result the way that Unix keeps track of time is important.
The Unix time and date system works by simply counting the seconds since the 1st of January 1970 - which is known as the Unix Epoch.
You might be able to guess that 1970 was the year that Unix was created - more or less.
If you want to be precise then the Unix epoch is 00:00:00 on Thursday 1 January 1970 UTC and the Unix time it is the number of seconds that have elapsed not counting leap seconds.
So using the Unix date/time system you can only work with dates/times after 1970?
This isn't quite true and the cartoon paints a slightly pessimistic picture. A Unix date/time is a signed 32-bit number, so you can use negative seconds, which give dates and time before 1970. Using the largest 32-bit negative number gives a date of Friday 13th in December 1901 as the earliest Unix date and so the cartoon really should read "Weird - My code's crashing when given pre-1901 dates", but presumably the program in question only worked with positive values.
As you might guess, if there is an earliest Unix date there is a latest one. The largest positive 32-bit integer represents a date of Tuesday 19th of January 2038 - and after this time all Unix time stamps will roll over and look like dates back in 1901.
This is the "Year 2038 Problem" and many think that it's a much bigger problem than the Millennium Bug - i.e. the roll over for the new century - ever was or could have been.
The reason is that Unix, and the Unix time system, has found its way into all sorts of places that you might not think of, including embedded computer systems such as washing machines and avionics.
If anything bad is going to happen then 3:14 and seven seconds UTC is the moment to look out for. Of course, things aren't quite this simple because many programs work with dates in the future. For example booking systems will start to make future bookings in 1901.
or email your comment to: email@example.com
To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+, Twitter, Linkedin or Facebook, install the I Programmer Toolbar or sign up for our weekly newsletter.
|Last Updated ( Sunday, 20 May 2012 )