Skip to main content

Module utc

Module utc 

Source
Expand description

Coordinated Universal Time (UTC) representation.

UTC is the primary civil time standard. It tracks TAI but is adjusted with leap seconds to stay within 0.9 seconds of UT1 (Earth rotation time). This module provides the UTC time scale type and calendar-based construction.

§Background

UTC was introduced in 1960 and has used its current leap second system since 1972. The offset TAI-UTC grows by 1 second each time a leap second is inserted (typically June 30 or December 31 at 23:59:60 UTC). As of 2024, TAI-UTC = 37 seconds.

TAI = UTC + (TAI-UTC offset from leap second table)
UTC day length = 86400s (normal) or 86401s (positive leap second)

§Usage

use celestial_time::{JulianDate, UTC};
use celestial_time::scales::utc::utc_from_calendar;

// From Unix timestamp
let utc = UTC::new(1704067200, 0); // 2024-01-01 00:00:00 UTC

// From calendar components
let utc = utc_from_calendar(2024, 1, 1, 12, 30, 45.5);

// From Julian Date
let utc = UTC::from_julian_date(JulianDate::j2000());

§Leap Second Handling

The utc_from_calendar function adjusts day length when a leap second occurs. It queries the TAI-UTC offset at multiple points within the day to detect the discontinuity and scales the time fraction accordingly.

§Precision

Internally stores time as a split Julian Date for nanosecond-level precision. The new() constructor separates days from sub-day time to preserve all significant digits in the fractional portion.

Structs§

UTC
UTC time scale backed by a split Julian Date.

Functions§

utc_from_calendar
Creates UTC from calendar components, handling leap seconds.