julian_date
Routine for calculating the Julian date
written by Jamie Stevens 2006
Definition:
double julian_date(time_t time_now)
Source:
julian_date.c
julian_date.h
Usage:
Send a time_t value to this routine, representing the time you want to turn into a Julian date. The return value of this routine is the Julian date for this time.
Example:
To get the Julian date for midnight 1st January 2007 UT, the following code will work:
#include <stdio.h>
#include <time.h>
#include "julian_date.h"
void main(){
double julday;
struct tm jt;
jt.tm_sec=jt.tm_min=jt.tm_hour=jt.tm_mon=0;
jt.tm_year=107;
jt.tm_mday=1;
julday=julian_date(timegm(&jt));
printf("julian date is %f\n",julday);
}
This program would output:julian date is 2454101.500000
