pub struct UTC(/* private fields */);Expand description
UTC time scale backed by a split Julian Date.
Wraps JulianDate to represent Coordinated Universal Time. Supports
construction from Unix timestamps, calendar components, or raw Julian Dates.
Implementations§
Source§impl UTC
impl UTC
Sourcepub fn new(seconds: i64, nanos: u32) -> Self
pub fn new(seconds: i64, nanos: u32) -> Self
Creates UTC from Unix timestamp (seconds and nanoseconds since 1970-01-01 00:00:00).
Days are computed separately from sub-day time to preserve precision. The resulting Julian Date uses jd1 for whole days and jd2 for the fractional part.
Sourcepub fn from_julian_date(jd: JulianDate) -> Self
pub fn from_julian_date(jd: JulianDate) -> Self
Creates UTC from a Julian Date.
Sourcepub fn j2000() -> Self
pub fn j2000() -> Self
Returns UTC at the J2000.0 epoch (2000-01-01 12:00:00 TT, JD 2451545.0).
Sourcepub fn to_julian_date(&self) -> JulianDate
pub fn to_julian_date(&self) -> JulianDate
Returns the underlying Julian Date.
Sourcepub fn add_seconds(&self, seconds: f64) -> Self
pub fn add_seconds(&self, seconds: f64) -> Self
Returns a new UTC offset by the given seconds.
Sourcepub fn to_iso8601(&self) -> String
pub fn to_iso8601(&self) -> String
Formats as ISO 8601 string (YYYY-MM-DDTHH:MM:SS.sss).
Falls back to “JD{value}” if calendar conversion fails.
Trait Implementations§
Source§impl From<JulianDate> for UTC
Converts JulianDate to UTC.
impl From<JulianDate> for UTC
Converts JulianDate to UTC.
Source§fn from(jd: JulianDate) -> Self
fn from(jd: JulianDate) -> Self
Source§impl ToTAI for UTC
impl ToTAI for UTC
Source§fn to_tai(&self) -> TimeResult<TAI>
fn to_tai(&self) -> TimeResult<TAI>
Convert UTC to TAI by adding the accumulated leap seconds.
Looks up the TAI-UTC offset for the given date and applies drift corrections for pre-1972 dates. Handles leap second boundaries correctly.
Source§impl ToUT1WithDUT1 for UTC
impl ToUT1WithDUT1 for UTC
Source§fn to_ut1_with_dut1(&self, dut1_seconds: f64) -> TimeResult<UT1>
fn to_ut1_with_dut1(&self, dut1_seconds: f64) -> TimeResult<UT1>
Convert UTC to UT1 by computing UT1-TAI from DUT1 and TAI-UTC.
The conversion uses the relationship:
UT1 - TAI = DUT1 - (TAI - UTC) = DUT1 - TAI_UTC_offsetThe TAI-UTC offset is looked up from the leap second table for the specific date. The result chains: UTC → TAI → UT1.
Source§impl ToUTC for UTC
impl ToUTC for UTC
Source§fn to_utc(&self) -> TimeResult<UTC>
fn to_utc(&self) -> TimeResult<UTC>
Identity conversion. Returns self unchanged.