jday(1) (version 2.4)

Name

jday, j2d - julian date conversion utilities

Synopsis

jday

jday [year [month [day [hour [minute [second]]]]]]

jday -d [-]year-mm-dd hh:mm:ss

j2d <julian decimal date>

jday --version

jday --h[elp]

j2d --version

j2d --h[elp]


Description

jday converts a calendar date, year/month/day hh:mm:ss to a decimal julian date.

j2d converts a julian date to a calendar date.

The julian date definition is the astronomical julian date. Day 0.0 is -4712 January 01 12:00:00 UT. There is a year 0 between year -1 and year 1. The years greater than 0 thus correspond to common era Julian/Gregorian calendar dates. 04 October 1582 Julian (JD 2299160) is followed by 15 October 1582 Gregorian (JD 2299161)

If no argument is given to jday , it prints the current julian date based on the system's date, time, and timezone setting. The julian date output is always to six decimal places, thus a precision of 1/1000000 of a day, or 0.0864 seconds. (although the system clock may not have that much precision) The accuracy of this output will depend upon the accuracy of the system clock setting and timezone configuration.

jday can take two forms of arguments. The year, month, day, hour, minute, second form is purely positional. They go in that order, and any that are not given are assumed to be the current date, time of the system. All of these arguments are simple integers.

The "-d [-]year-mm-dd hh:mm:ss" form provides a complementary function to j2d . This input form would be the output of j2d and thus will be the inverse function of j2d . Again, all of these numbers are simple integers.

j2d must have an argument, the julian date. It will output the date in the form of "year/mm/dd hh:mm:ss" and the year can be negative up to -4712. This single argument is a (double) type.

See Also

See also: www.cl.cam.ac.uk/~mgk25/iso-time.html ISO-8601 definitions

Examples

$ jday
2452438.816424

$ j2d 2452438.816424
2002-06-13 07:35:39

$ jday -d 2002-06-13 07:35:39
2452438.816424

$ jday 1970 1 1 12 0 0
2440588.000000

$ jday -4712 1 1 12 0 0
0.0000

$ j2d 0
-4712-01-01 12:00:00

$ j2d `jday`
2002-06-13 07:43:49

Known Bugs

Since the resolution of each function is different, there is no exact inverse relationship. jday returns the julian date accurate to 1/1000000 of a day (0.084 seconds). On the other hand, j2d returns accuracy only to the second, which is much less than jday.


CalDate(3), JulDate(3) (version 2.4)

Name

CalDate, JulDate - functions available in libjday.a

Synopsis

cc [flag ...] file ... -ljday [library ...]

#include <jday.h>

UTinstant UT;

double JulDate(&UT);

int CalDate(&UT);


typedef struct ut_instant {
        double  j_date; /* julian decimal date, 0 = 01 Jan -4712 12 HR UT */
        int	year; /* year, valid range [-4,712, +2,147,483,647] */
        int     month;  /*      [1-12]  */
        int     day;    /*      [1-31]  */
        int     i_hour; /*      [0-23]  */
        int     i_minute;       /*      [0-59]  */
        double  second;		/*      [0-59.9999]  */
        double  d_hour;         /* [0.0-23.9999] includes minute and second */
        double  d_minute;       /*      [0.0-59.9999] includes second   */
        int     weekday;        /*      [0-6]   */
        int     day_of_year;    /*      [1-366] */
} UTinstant, * UTinstantPtr;

Description

Set the structure elements for year, month, day, i_hour, i_minute, and second to call JulDate(). It will calculate the structure elements j_date and weekday, and return the value of j_date.

Set the structure element for j_date to call CalDate(). It will calculate all of the other elements of the structure, and return the calculated year.

There is no boundary or legal date checking in the calculations. If invalid data is given to the functions, the results are undetermined. However, CalDate() will return valid dates when they are in range.