Converting Dates From and To Julian Days

Julian dates represent the number of days elapsed since a certain reference date in the past. The reference date from which all Julian dates are measured has been chosen by astronomers to be January 1, 4713 B.C. Julian dates are used for comparing dates and to store dates as a long integer value instead of a string.

To convert a date to a Julian date, call the date to Julian function, date_tojul():

long date_tojul(date_stp, format_stp)
 
UCHAR *date_stp;
/* Date string to convert
*/
UCHAR *format_stp;
/* Date format string to use
*/

date_tojul() returns the Julian date as a long integer.

To convert a Julian date back to a date string, call the date from Julian function, date_frjul():

int date_frjul(date_stp, jul_date, format_stp)
 
UCHAR *date_stp;
/* Date string to store date in
*/
long jul_date;
/* Julian date to convert
*/
UCHAR *format_stp;
/* Date format string to use
*/

date_frjul() places the resulting date string, formatted according to the specified format string, in the pointer to the date string passed in the call.

Note that you must allocate memory for the string used to receive the formatted date. This string must be long enough to accept a date of the specified format.


Home Contents Previous Next