getTimes static method

Future<Map<String, DateTime>> getTimes(
  1. DateTime date,
  2. num lat,
  3. num lng
)

Implementation

static Future<Map<String, DateTime>> getTimes(
    DateTime date, num lat, num lng) async {
  var lw = rad * -lng;
  var phi = rad * lat;

  var d = toDays(date);
  var n = julianCycle(d, lw);
  var ds = approxTransit(0, lw, n);

  var M = solarMeanAnomaly(ds);
  var L = eclipticLongitude(M);
  var dec = declination(L, 0);

  var jnoon = solarTransitJ(ds, M, L);
  dynamic time, jset, jrise;
  int i;

  var result = {
    "solarNoon": fromJulian(jnoon),
    "nadir": fromJulian(jnoon - 0.5)
  };

  for (i = 0; i < times.length; i += 1) {
    time = times[i];

    jset = getSetJ(time[0] * rad, lw, phi, dec, n, M, L);
    jrise = jnoon - (jset - jnoon);

    result[time[1]] = fromJulian(jrise);
    result[time[2]] = fromJulian(jset);
  }

  return result;
}