pub struct BrightDate {
pub value: f64,
pub precision: Precision,
pub is_tai: bool,
}Expand description
Immutable BrightDate value — decimal days since J2000.0 epoch.
This is the primary type for nearly all time operations. Wrap a raw f64
value to get the full BrightDate API including formatting, arithmetic, and
conversion methods.
Fields§
§value: f64Raw decimal-day value since J2000.0
precision: PrecisionDisplay precision (decimal places)
is_tai: boolWhether this value is on the TAI timescale
Implementations§
Source§impl BrightDate
impl BrightDate
Sourcepub fn from_value(value: f64) -> Self
pub fn from_value(value: f64) -> Self
Create from a raw f64 value (decimal days since J2000.0).
Sourcepub fn from_value_with_options(value: f64, options: BrightDateOptions) -> Self
pub fn from_value_with_options(value: f64, options: BrightDateOptions) -> Self
Create from a raw value with full options.
Sourcepub fn from_date_time(dt: DateTime<Utc>) -> Self
pub fn from_date_time(dt: DateTime<Utc>) -> Self
Create from a chrono::DateTime<Utc>.
Sourcepub fn from_unix_ms(ms: f64) -> Result<Self, BrightDateError>
pub fn from_unix_ms(ms: f64) -> Result<Self, BrightDateError>
Create from a Unix timestamp in milliseconds.
Sourcepub fn from_unix_seconds(s: f64) -> Result<Self, BrightDateError>
pub fn from_unix_seconds(s: f64) -> Result<Self, BrightDateError>
Create from a Unix timestamp in seconds.
Sourcepub fn from_julian_date(jd: f64) -> Self
pub fn from_julian_date(jd: f64) -> Self
Create from a Julian Date.
Sourcepub fn from_modified_julian_date(mjd: f64) -> Self
pub fn from_modified_julian_date(mjd: f64) -> Self
Create from a Modified Julian Date.
Sourcepub fn from_iso(s: &str) -> Result<Self, BrightDateError>
pub fn from_iso(s: &str) -> Result<Self, BrightDateError>
Create from an ISO 8601 string.
Sourcepub fn from_gps_time(gps_week: u32, gps_seconds: f64) -> Self
pub fn from_gps_time(gps_week: u32, gps_seconds: f64) -> Self
Create from GPS week number and seconds within that week.
Sourcepub fn to_date_time(&self) -> DateTime<Utc>
pub fn to_date_time(&self) -> DateTime<Utc>
Convert to a chrono::DateTime<Utc>.
Sourcepub fn to_unix_ms(&self) -> f64
pub fn to_unix_ms(&self) -> f64
Convert to Unix milliseconds.
Sourcepub fn to_unix_seconds(&self) -> f64
pub fn to_unix_seconds(&self) -> f64
Convert to Unix seconds.
Sourcepub fn to_julian_date(&self) -> f64
pub fn to_julian_date(&self) -> f64
Convert to Julian Date.
Sourcepub fn to_modified_julian_date(&self) -> f64
pub fn to_modified_julian_date(&self) -> f64
Convert to Modified Julian Date.
Sourcepub fn to_gps_time(&self) -> (u32, f64)
pub fn to_gps_time(&self) -> (u32, f64)
Convert to GPS time (gps_week, gps_seconds).
Sourcepub fn to_tai(&self) -> Self
pub fn to_tai(&self) -> Self
Mark this BrightDate as TAI-flagged. In v1.0 the underlying value is always TAI-coherent, so this only toggles the display flag.
Sourcepub fn to_utc(&self) -> Self
pub fn to_utc(&self) -> Self
Mark this BrightDate as UTC-flagged. In v1.0 the underlying value is always TAI-coherent, so this only toggles the display flag.
Sourcepub fn tai_utc_offset_seconds(&self) -> i32
pub fn tai_utc_offset_seconds(&self) -> i32
Current TAI − UTC offset in whole seconds at this instant.
Sourcepub fn add_millidays(&self, md: f64) -> Self
pub fn add_millidays(&self, md: f64) -> Self
Add millidays.
Sourcepub fn add_microdays(&self, ud: f64) -> Self
pub fn add_microdays(&self, ud: f64) -> Self
Add microdays.
Sourcepub fn difference(&self, other: &Self) -> f64
pub fn difference(&self, other: &Self) -> f64
Signed difference self − other in decimal days.
Sourcepub fn absolute_difference(&self, other: &Self) -> f64
pub fn absolute_difference(&self, other: &Self) -> f64
Absolute difference from other in decimal days.
Sourcepub fn approx_eq(&self, other: &Self, tolerance: Option<f64>) -> bool
pub fn approx_eq(&self, other: &Self, tolerance: Option<f64>) -> bool
Test equality within tolerance decimal days (default: 1 microday).
Sourcepub fn is_in_range(&self, start: &Self, end: &Self) -> bool
pub fn is_in_range(&self, start: &Self, end: &Self) -> bool
True if self falls in [start, end].
Sourcepub fn lerp(&self, other: &Self, t: f64) -> Self
pub fn lerp(&self, other: &Self, t: f64) -> Self
Linear interpolation between self and other at parameter t ∈ [0,1].
Sourcepub fn floor_to_day(&self) -> Self
pub fn floor_to_day(&self) -> Self
Floor to the nearest whole day boundary.
Sourcepub fn ceil_to_day(&self) -> Self
pub fn ceil_to_day(&self) -> Self
Ceiling to the nearest whole day boundary.
Sourcepub fn round_to_milliday(&self) -> Self
pub fn round_to_milliday(&self) -> Self
Round to nearest milliday.
Sourcepub fn round_to_microday(&self) -> Self
pub fn round_to_microday(&self) -> Self
Round to nearest microday.
Sourcepub fn format(&self) -> String
pub fn format(&self) -> String
Format as decimal-day string with this instance’s precision, e.g. "9622.50417".
Sourcepub fn decompose(&self) -> BrightDateComponents
pub fn decompose(&self) -> BrightDateComponents
Full decomposed struct.
Sourcepub fn format_full(&self) -> FormattedBrightDate
pub fn format_full(&self) -> FormattedBrightDate
Full formatted breakdown.
Sourcepub fn to_log_string(&self) -> String
pub fn to_log_string(&self) -> String
Compact log string, e.g. "[9622.50417]".
Sourcepub fn to_prefixed_string(&self, prefix: Option<&str>) -> String
pub fn to_prefixed_string(&self, prefix: Option<&str>) -> String
Prefixed string, e.g. "BD:9622.50417".
Sourcepub fn format_duration_to(&self, other: &Self) -> String
pub fn format_duration_to(&self, other: &Self) -> String
Format duration from self to other.
Sourcepub fn duration_to(&self, other: &Self) -> BrightDuration
pub fn duration_to(&self, other: &Self) -> BrightDuration
Duration breakdown.
Sourcepub fn format_range_to(&self, other: &Self) -> String
pub fn format_range_to(&self, other: &Self) -> String
Range string for self..=other.
Trait Implementations§
Source§impl Add<f64> for BrightDate
impl Add<f64> for BrightDate
Source§impl Clone for BrightDate
impl Clone for BrightDate
Source§fn clone(&self) -> BrightDate
fn clone(&self) -> BrightDate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BrightDate
impl Debug for BrightDate
Source§impl<'de> Deserialize<'de> for BrightDate
impl<'de> Deserialize<'de> for BrightDate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for BrightDate
impl Display for BrightDate
Source§impl PartialEq for BrightDate
impl PartialEq for BrightDate
Source§fn eq(&self, other: &BrightDate) -> bool
fn eq(&self, other: &BrightDate) -> bool
self and other values to be equal, and is used by ==.