use integer variables

use long (especially for JD) as julian date's can exceed the integer limits.

added some naming to the code above to better understand it.

Definition: The Julian date (JD) is a continuous count of days from 1 January 4713 BC.

`long JulianDate(int year, int month, int day)`

{

long centuries = year/100;

long leaps = centuries/4;

long leapDays = 2 - centuries + leaps; // note is negative!!

long yearDays = 365.25 * (year + 4716); // days until 1 jan this year

long monthDays = 30.6001* (month + 1); // days until 1st month

long jd = leapDays + days + monthDays + yearDays -1524.5;

return jd;

}

There are also formulas for calculating back to Gregorian e.g. when will I be 10000 or 20000 days old.

- http://aa.usno.navy.mil/faq/docs/JD_Formula.php -

- http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html -

coding this is left as an exercise for the reader