///|
const DayMs : Double = 86400000.0
///|
const J1970 : Double = 2440588.0
///|
const J2000 : Double = 2451545.0
///|
const Rad : Double = 0.017453292519943295
///|
fn to_days(date : Instant) -> Double {
date.ms / DayMs - 0.5 + J1970 - J2000
}
///|
fn from_days(d : Double) -> Instant {
{ ms: @math.trunc((d + J2000 + 0.5 - J1970) * DayMs), }
}
///|
/// Julian date on the UTC scale (not TT).
pub fn Instant::julian_day(self : Instant) -> Double {
self.ms / DayMs - 0.5 + J1970
}
///|
/// The UTC calendar day containing the instant; not an observer's civil timezone.
pub fn Instant::utc_midnight(self : Instant) -> Instant {
{ ms: @math.floor(self.ms / DayMs) * DayMs, }
}
// JavaScript Math.round rounds negative half ties toward +infinity, unlike many runtimes.
///|
fn js_round(x : Double) -> Double {
@math.floor(x + 0.5)
}