[time-nuts] TEC party file format?

Hal Murray hmurray at megapathdsl.net
Thu Jun 30 18:24:53 UTC 2011

> Any advice on an easy way to convert my timestampts from time_t to  mjd?
> I'm using C here. 

It's trivial.  All you have to do is offset by the difference in starting 

MJD is usually printed as an integer rather than year-month-day format.  (My 
sample is tiny so that could easily be bogus.)

This is what I use to make log files similar to what ntpd writes.

#define MJD_1970        40587           /* MJD for 1 Jan 1970 */

    struct timeval stop;

    gettimeofday(&stop, NULL);

    day = stop.tv_sec / 86400 + MJD_1970;
    sec = stop.tv_sec % 86400;
    msec = stop.tv_usec / 1000;

    printf(file, "%d %d.%03d", day, sec, msec);

These are my opinions, not necessarily my employer's.  I hate spam.

More information about the time-nuts mailing list