secondsInUtcDay function
Calculates and returns the number of seconds (including any
leap seconds) that are in the UTC day containing the specified
second, utc
.
Implementation
double secondsInUtcDay(double utc) {
// Adjust to midnight by subtracting 43200.
final d0 = (utc - 43200) ~/ 86400.0;
final d1 = d0 + 1;
final tai1 = TimeInstant.UTC.toMks(d0 * 86400.0);
// UTC seconds at (close to) the following UTC midnight
// (as long as it's well past noon, which is when the leap seconds are added)
final tai2 = TimeInstant.UTC.toMks(d1 * 86400.0);
// Return number of seconds on this UTC day
return (tai2 - tai1).toDouble();
}