Date Time Library
This library provides a set of high precision date and time classes covering a large time span.
A consistent interface (within the limitations of the languages) is provided for C++, Java and Python. The precision of the dates and times across all languages and platforms is at least 1ns.
The calendars used are the Julian proleptic/Julian and Gregorian proleptic/Gregorian calendars. The changeover from the Julian Calendar to the Gregorian Calender occurred in 1582 with Thursday, 1582 October 04, being the last day of the Julian Calendar and the next day: Friday, 1582 October 15, being the first day of the Gregorian Calendar.
Primary references for algorithms were:
- "Explanatory Supplement to the Astronomical Almanac", Ed. P. Kennith Seidelmann, University Science Books, 1992.
- "Astronomical Algorithms", Jan Meeus, Willmann-Bell, Inc., 1991.
Testing was done using http://aa.usno.navy.mil/data/docs/JulianDate.php.
- integer must be at least 32-bit
- floating point must be 8-byte double precision (IEEE 754).
- In C++: long long must be at least 64-bit.
The library has been implemented in:
- Python 3.x,
- Java 7/8,
- C++: C++11 compliant compiler.
The implementations are coded in C++, Java and Python. For each language there is a set of tests to verify the functionality of the classes.
Generally it should be easy to code in any of the languages as the classes mostly have similar names and the methods in the classes are generally similar. C++ class and method names are regarded as the standard. This means that in the case of Java, method names start with a capital letter and, in the case of Python, some methods have names to reflect the data types they handle.
- C++ code is considered as the reference standard with the Java and Python code being based on this implementation.
- Java does not have multiple inheritance so the classes DateConversions and TimeConversions have been merged into the one class DateTimeConversions. This also means that the YMDHMS class has two fields of type YMD and HMS.
- Java does not have operator overloading so the following method names correspond to the overloaded C++ operators: assign (=), eq (==), ne (!=), lt (<), le (<=), gt (>), ge (>=), add (+), inc (+=), sub (-), dec (-=).
- The python classes generally type check arguments and will automatically convert input parameters to the correct type where possible.
- Because of the Duck Typing feature of Python, some methods explicitly check the type of their parameters.
Instantiating the JulianDateTime class should give you access to all the necessary methods for date and time manipulations including addition and date differences. This class stores the date and time and inherits DateConversions and TimeConversions (DateTimeConversions in the case of Java). These conversion classes do not store any data, they just provide methods for date and time conversions. This means that you can use these to implement your own specific functionality.
In the JulianDateTime class, dates and times are represented as a continuous count of days and fractions of a day from -13200 August 15, Greenwich noon Julian proleptic calendar (JD-3100015.50) to 17191-Mar-15, Greenwich noon Gregorian Calendar (JD8000016.50). The underlying storage is that of an integer representing the Julian Day Number for noon on that date and a floating-point number representing the fraction of the day running from midday to midday (always positive). This should yield a precision of around 1ns covering this period.
Examples are provided for C++, Java and Python 3. In addition a QT5 and an android example are also provided.
Tests have been written for for C++, Java and Python 3. In the case of a discrepancy, the C++ tests are the reference ones with nearly 100% coverage. Tests for Java and Python also provide similar coverage.
This can be generated via the scripts MakeAllTheDocumentation.sh for Linux and Apple, MakeAllTheDocumentation.cmd for Windows. In order to generate the documentation the following programs must be installed, Doxygen (for C++ and Java), Java Development Kit (for Java) and Sphinx (for Python).