Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!acornrc!rbbb From: rbbb@acornrc.UUCP (David Chase) Newsgroups: comp.lang.c Subject: Re: Timekeeping in ANSI C Message-ID: <594@acornrc.UUCP> Date: 10 Feb 88 18:59:18 GMT References: <461@auvax.UUCP> <28700025@ccvaxa> <7159@brl-smoke.ARPA> <2527@haddock.ISC.COM> Organization: Acorn Research Centre, Palo Alto, CA Lines: 23 Summary: here's one sensible implementation that I've seen I'm in the middle of porting a C library from one machine to another. In this library, time is represented as a structure containing two unsigned long quantities (hi and lo). The time is encoded as: hi contains (centi-seconds since 1900 began) / 65536 The high order bit on indicates a bogus time. lo contains ((centi-seconds since 1900 began) % 65536) * 65536 + left-over microseconds. OR cccccccc ccccuuuu hi lo This structure can encode dates from 1900 AD to something like 47000 AD. It is a pill to work with, of course, which is why you write a bunch of library routines to work with the time structures (add, subtract, convert to and from a date+time form, etc). But don't listen to me. Go ahead, use the Unix format. I should still be alive on 'Mon Jan 18 19:14:07 2038 (GMT)' when all you code dies. I'll gloat. David Chase Olivetti Research Center, Menlo Park