pub struct CivilDate {
pub year: i32,
pub month: u8,
pub day: u8,
}Expand description
Proleptic Gregorian calendar date.
A minimal date type used for epoch definitions and calendar arithmetic.
This type does not include time-of-day, timezone, or leap second information.
§Validity
No validation is performed. Invalid dates are allowed and may produce undefined calendar results.
§Examples
use gnss_time::{CivilDate, GALILEO_EPOCH, GPS_EPOCH};
let delta = GPS_EPOCH.seconds_until(GALILEO_EPOCH);
assert_eq!(delta, 619_315_200);Fields§
§year: i32Year (e.g. 1980)
month: u8Month (1–12)
day: u8Day of month (1–31)
Implementations§
Source§impl CivilDate
impl CivilDate
Sourcepub const fn new(year: i32, month: u8, day: u8) -> Self
pub const fn new(year: i32, month: u8, day: u8) -> Self
Creates a new calendar date.
No validation is performed.
Sourcepub const fn days_from_unix(self) -> i64
pub const fn days_from_unix(self) -> i64
Returns the number of days since the Unix epoch (1970-01-01).
Negative values indicate dates before the epoch.
Uses Howard Hinnant’s algorithm.
Sourcepub const fn days_until(self, other: CivilDate) -> i64
pub const fn days_until(self, other: CivilDate) -> i64
Returns the signed difference in days (other - self).
Sourcepub const fn seconds_until(self, other: CivilDate) -> i64
pub const fn seconds_until(self, other: CivilDate) -> i64
Returns the difference in whole seconds.
Time-of-day is not considered.
Sourcepub const fn nanos_until(self, other: CivilDate) -> i64
pub const fn nanos_until(self, other: CivilDate) -> i64
Returns the difference in nanoseconds.
Time-of-day is not considered.
Trait Implementations§
impl Copy for CivilDate
impl Eq for CivilDate
impl StructuralPartialEq for CivilDate
Auto Trait Implementations§
impl Freeze for CivilDate
impl RefUnwindSafe for CivilDate
impl Send for CivilDate
impl Sync for CivilDate
impl Unpin for CivilDate
impl UnsafeUnpin for CivilDate
impl UnwindSafe for CivilDate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more