Skip to main content

parse_kernel_date

Function parse_kernel_date 

Source
pub fn parse_kernel_date(text: &str) -> Result<KernelDate, TimeError>
Expand description

Resolves a kernel date literal such as @2000-JAN-01-12:00:00.

The leading @ is required. The result is the exact N0067/TPARSE value: proleptic-Gregorian calendar arithmetic expressed as seconds past J2000, with no leap-second or time-scale conversion.

use stkcraft_time::kernel_date::parse_kernel_date;

let epoch = parse_kernel_date("@2001-FEB-29")?;
assert_eq!(epoch.seconds_past_j2000, 36_676_800.0);
assert_eq!((epoch.year, epoch.month, epoch.day), (2001, 3, 1));

ยงErrors

Returns TimeError::KernelDateUnsupported when the literal is not a supported form. It never returns a missing-kernel error, because a date literal is present data, not an absent variable.