convertJulianDayToSolarDate static method

DateTime convertJulianDayToSolarDate(
  1. int jd
)

Convert a Julian day number to day/month/year. Parameter jd is an integer.

Implementation

static DateTime convertJulianDayToSolarDate(int jd) {
  int a, b, c, d, e, m, day, month, year;
  if (jd > 2299160) {
    a = jd + 32044;
    b = ((4 * a + 3) / 146097).floor();
    c = a - ((b * 146097) / 4).floor();
  } else {
    b = 0;
    c = jd + 32082;
  }
  d = ((4 * c + 3) / 1461).floor();
  e = c - ((1461 * d) / 4).floor();
  m = ((5 * e + 2) / 153).floor();
  day = e - ((153 * m + 2) / 5).floor() + 1;
  month = m + 3 - 12 * (m / 10).floor();
  year = b * 100 + d - 4800 + (m / 10).floor();
  return DateTime(year, month, day);
}