pub trait LeapSecondProvider {
// Required methods
fn leap_seconds_on_date(&self, utc_date: Date) -> (bool, i32);
fn leap_seconds_at_time(&self, utc_time: UtcTime) -> (bool, i32);
}Expand description
Since leap seconds are hard to predict in advance (due to irregular variations in the Earth’s
rotation), their insertion and deletion is based on short-term predictions. This means that
it is not possible to develop a leap second table that holds “for all eternity” without
external influence. Different applications may have different manners of obtaining these
updates from external sources - if at all possible. To accommodate all such applications, we
support a generic manner of introducing leap seconds, via the LeapSecondProvider interface.
Any type that implements this trait may be used to determine when leap seconds occur, and how often they do. In this manner, one may opt for a static leap second table but also easily swap it for a table that updates based on the published IANA list, on GNSS constellation navigation messages, or custom telecommands (for spacecraft, for example).
Required Methods§
Sourcefn leap_seconds_on_date(&self, utc_date: Date) -> (bool, i32)
fn leap_seconds_on_date(&self, utc_date: Date) -> (bool, i32)
For any given date (expressed in UTC), determines whether a leap second was inserted at the end of that day. In tandem, returns the accumulated number of leap seconds before (!) that date.
Sourcefn leap_seconds_at_time(&self, utc_time: UtcTime) -> (bool, i32)
fn leap_seconds_at_time(&self, utc_time: UtcTime) -> (bool, i32)
Given some UTC time, returns the number of leap seconds that apply, and whether the requested date-time is a leap second (exactly).