Imperial College London

 


MJDtime: C library for date-time conversion


MJDtime current version is 1.05

This is C software for converting between various UTC date/time formats: Modified Julian Date, Julian Date, NASA CDF Epoch, ISO time strings and broken down time (year, month, day [or day of year], hour, minute, second [as a double]). It understands both Julian and Gregorian calendars and both CE(AD) and BCE(BC) dates.

It can also format the date/time into a text string using all the format specifiers available in the standard library strftime() with the same syntax. Additionally it can print decimal fractions of seconds. It differs from strftime() in that the locale is ignored and dates and times are always in UTC.

It can also determine the difference between two date/time structures in either days or seconds as a double, and provide the day of week and week of year for a specified date.

The default changeover from Julian to Gregorian Calendar is from 15 October 1582 (Gregorian), but this can be set by the user in software.

Date and time are stored internally as a structure holding an integer value for the MJD day and a double as seconds from the start of this day. The seconds field may be negative or exceed a full day. Within a day time can be handled down to picosecond accuracy, but for longer time spans accuracy diminishes. For most applications Microsecond accuracy is attainable (note that conversion to/from CDF Epoch will be limited to millisecond accuracy, and Epoch16 is not yet included).


History

03 Feb 2009: v1.01:

Fixes bus error in strfMJD() when "%." format is used for time with hour, minute, second all zero.

Also removes trailing space in getISOString() and improves formatting of "%." and "%{1-9}" in strfMJD().

04 Feb 2009: v1.02:

Changes format in getISOstring() from %g to %f (change by PLPLOT team).

05 Feb 2009: v1.03:

Fixes getDiffSecs() and getDiffDays().

25 Feb 2009: v1.04:

Incorporates modifications provided by Alan Irwin of the PLPLOT team.

Allows the user to set the date for switching between Julian and Gregorian calendars.

03 Mar 2009: v1.05:

Improves formatting of seconds field by rounding before call to breakDownMJD() in strfMJD().


Obtaining MJDtime

The software source and documentation are available as a compressed tar file, MJDtime.tar.gz.


Documentation

The routines are described in detail in

· 


Authors

This software was written by the QSAS team at the Cluster Science Centre, Space and Atmospheric Physics, Imperial College, London.

MJDtime is developed as part of the Cluster Science Centre within the UK and funded by the Science and Technology Facilities Council . The software is provided as is under the LGPL public licence, though IC retains the copyright. No liability is accepted for any damage resulting from the installation or use of this software, and no guarantee of its suitability is implied for any use. Copyright.


Last up-dated 25 February 2009


Send comments and suggestions to csc-support-dl@imperial.ac.uk

Imperial College London is not responsible for the content of external sites.