I don't understand the purpose of the Unix time / epoch, to my understanding the number of seconds elapsed since January 1st, 1970. This seems wholly arbitrary to me. Why not simply use a timestamp in the form of month, day, year?
-
3How would you represent this timestamp of yours in memory? How many bytes of memory would that take? How many bytes of memory do you think they had in the 70s? :)– univerioJun 29, 2014 at 3:48
-
2Measuring time in seconds is simpler than "simply" using three integers that you have to interpret in very, very screwy ways.– tmyklebuJun 29, 2014 at 3:48
3 Answers
Not to get existential, but all time is arbitrary.
This year is 2014 A.D. meaning it's been 2014 years since the epoch used in the Julian and Gregorian calendars. You've got to have a reference or starting point in time, or epoch, and the engineers at Bell decided to pick their own.
From this wired article:
The date was programmed into the system sometime in the early 70s only because it was convenient to do so, according to Dennis Ritchie, one the engineers who worked on Unix at Bell Labs at its inception.
Quoting Ritchie himself:
"At the time we didn't have tapes and we had a couple of file-systems running and we kept changing the origin of time. So finally we said, 'Let's pick one thing that's not going to overflow for a while.' 1970 seemed to be as good as any. "
I encourage you to watch this YouTube video: https://www.youtube.com/watch?v=-5wpm-gesOY
The tl;dr of the video is that countries deal with dates and times in massively inconsistent ways, and any programmer trying to deal with all of them is going to go crazy.
Rather than apply deltas to the date/time fields of your hypothetical struct (Which is a complicated calculation even when the delta stays constant relative to your base), having "time" as a single number means you just need to apply rules to a common base standard.