UT2 top-level property
Universal Time (UT2): UT2 = UT1 + 0.022 sin(2PIt) - 0.012 cos(2PIt) - 0.006 sin(4PIt) + 0.007 cos(4PIt), where t = the date in Besellian years
Implementation
// ignore: non_constant_identifier_names
final TimeInstantUnits UT2 =
TimeInstantUnits('Universal Time (UT2)', null, 'UT2', null, 1.0, false, 0.0, (dynamic val) {
//double d = val is num ? val.toDouble() : val is Number ? val.toDouble() : 0.0;
final d = UT1.fromMks(val); // UT1
const twoPI = 2.0 * pi;
const fourPI = 2.0 * twoPI;
final t = B.fromMks(UT1.toMks(d)).toDouble();
return d + (0.022 * sin(twoPI * t) - 0.012 * cos(twoPI * t) - 0.006 * sin(fourPI * t) + 0.007 * cos(fourPI * t));
}, (dynamic val) {
var d = val is num
? val.toDouble()
: val is Number
? val.toDouble()
: 0.0;
const twoPI = 2.0 * pi;
const fourPI = 2.0 * twoPI;
final t = B.fromMks(UT1.toMks(d)).toDouble(); // besselian -- use UT2 value as UT1... close enough
d -= 0.022 * sin(twoPI * t) - 0.012 * cos(twoPI * t) - 0.006 * sin(fourPI * t) + 0.007 * cos(fourPI * t); // UT1
return UT1.toMks(d);
});