Interesting dates in computer programming

Everybody knows about the Linux “epoch”, as in January 1st, 1970 UTC.

Some people might remember the original Mac OS equivalent, which was January 1st, 1904. From what I remember back in the day, Jerome Coonen picked that date (instead of 1900) because it simplified the leap year calculations. And using an unsigned 32 bit value for seconds meant that Macs could handle dates up to 2023 or some point way in the future.

Then yesterday I came across the MUMPS/Caché “$h” date format, which is described as:

This format returns the date as the number of days since 1st January 1841, and the time as the number of seconds since midnight.

I was speculating with my friend as to why they picked 1841, and guessed that this was some convenient date (similar to the Mac 1904 choice) that was before the birthdate of the oldest person they could imagine being in the system, back in the 1960s.

After turning to the Source of Truth (Wikipedia’s article on MUMPS), it seems like our guess was correct. James Poitras explains why he picked this odd date:

I remembered reading of the oldest (one of the oldest?) U.S. citizen, a Civil War veteran, who was 121 years old at the time. Since I wanted to be able to represent dates in a Julian-type form so that age could be easily calculated and to be able to represent any birth date in the numeric range selected, I decided that a starting date in the early 1840s would be ‘safe.’ Since my algorithm worked most logically when every fourth year was a leap year, the first year was taken as 1841. The zero point was then December 31, 1840

Advertisements

4 Responses to Interesting dates in computer programming

  1. I wrote an integration between Ensemble and Svn back in the day. I always feel bad for anybody working with Mumps (or even M).

  2. Steve Yerow says:

    The syntax of MUMPS (M), which I used extensively for 20+ years, allows easy date/time storage and calculations. I came here looking for an easy way to calculate days since a start point in SQL – without any time considerations – and found myself longing for the MUMPS format.

    Haven’t programmed for about 15 years now, so I’m sure it’s easier than I’m making it… but if you know an algorithm to compute ‘days since Jan 01, 2011’ that will work for the next 10+ years, email me, please. I’m too lazy these days. Missing MUMPS !

  3. Valerie says:

    Programming in M (using InterSystems Caché or GT.M) ruins you for programming in other languages – M is so much clearer and easier to program in. I feel sorry for people who have to program in “ordinary” languages.

  4. Michal Mit says:

    The M expression to convert $H time format to EPOCH:
    (($P(TimeH,”,”,1)-47117)*86400)+$P(TimeH,”,”,2)
    Where the TimeH is the variable containing the time in the $H format.

    The current timestamp in Caché Object Script – $ZTIMESTAMP contains fractions of seconds, thus the conversion to EPOCH reads:
    $P((($P($ZTS,”,”,1)-47117)*86400)+$P($ZTS,”,”,2),”.”,1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: