jamie stevens'
code


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



this page last modified @ 2006/11/30 13:38
website maintained by jamie stevens, school of mathematics and physics, university of tasmania
this page, its contents and style are the responsibility of the author, and do not necessarily reflect the opinions of the university of tasmania
all images on this site are copyright jamie stevens unless specified otherwise
best viewed at resolutions higher than 800x600 (this centre thing is 600 pixels wide) and with a recent browser
Firefox 2