JD_UTC top-level property

TimeInstantUnits JD_UTC
final

Julian Date in the UTC scale

Implementation

// ignore: non_constant_identifier_names
final TimeInstantUnits JD_UTC =
    TimeInstantUnits('Julian Date (UTC)', null, 'JD(UTC)', null, 86400.0, false, -2436204.5, (dynamic val) {
  final d = UTC.fromMks(val).toDouble(); // UTC seconds
  final jd0 = d ~/ 86400.0; // integer UTC days

  // Fractional UTC days taking into account any leap seconds
  // for the particular UTC day in question
  final frac = (d - (jd0 * 86400.0)) / secondsInUtcDay(d);

  return Double(2436204.5 + jd0 + frac);
}, (dynamic val) {
  var d = val is num
      ? val.toDouble()
      : val is Number
          ? val.toDouble()
          : 0.0;

  // Adjust origin to TAI/UTC origin
  d -= 2436204.5;

  // Convert to seconds UTC
  final jd0 = d.toInt();
  d = (jd0 * 86400.0) + ((d - jd0) * secondsInUtcDay(d * 86400.0));

  return UTC.toMks(d);
});