ModifiedJulianDate

Struct ModifiedJulianDate 

Source
pub struct ModifiedJulianDate<Representation, Period: ?Sized = SecondsPerDay> { /* private fields */ }
Expand description

The Modified Julian Day (MJD) representation of any given date.

Implementations§

Source§

impl<Representation> ModifiedJulianDate<Representation, SecondsPerDay>

Source

pub const fn new(mjd: Representation) -> Self

Convenience function that constructs a modified Julian day directly from some day count.

Source§

impl<Representation, Period: ?Sized> ModifiedJulianDate<Representation, Period>

Source

pub const fn from_time_since_epoch( time_since_epoch: Duration<Representation, Period>, ) -> Self

Constructs a new MJD directly from some duration since the MJD epoch, November 17 1858.

Source

pub const fn time_since_epoch(&self) -> Duration<Representation, Period>
where Representation: Copy,

Returns the time since the MJD epoch of this day.

Source

pub fn from_date(date: Date<Representation>) -> Self
where Representation: Copy + From<i32> + Add<Representation, Output = Representation> + ConvertUnit<SecondsPerDay, Period>,

Constructs a modified Julian date from some given calendar date.

Source

pub fn into_date(&self) -> Date<Representation>
where Representation: Copy + From<i32> + Sub<Representation, Output = Representation> + ConvertUnit<Period, SecondsPerDay>,

Converts this modified Julian date into the equivalent “universal” calendar date.

Source

pub fn cast<Target>(self) -> ModifiedJulianDate<Target, Period>
where Representation: Into<Target>,

Infallibly converts towards a different representation.

Source

pub fn try_cast<Target>( self, ) -> Result<ModifiedJulianDate<Target, Period>, <Representation as TryIntoExact<Target>>::Error>
where Representation: TryIntoExact<Target>,

Converts towards a different representation. If the underlying representation cannot store the result of this cast, returns None.

Source§

impl ModifiedJulianDate<i32>

Source

pub fn from_historic_date( year: i32, month: Month, day: u8, ) -> Result<Self, InvalidHistoricDate>

Creates a Date based on a year-month-day date in the historic calendar.

Source

pub fn from_gregorian_date( year: i32, month: Month, day: u8, ) -> Result<Self, InvalidGregorianDate>

Creates a Date based on a year-month-day date in the proleptic Gregorian calendar.

Source

pub fn from_julian_date( year: i32, month: Month, day: u8, ) -> Result<Self, InvalidJulianDate>

Creates a Date based on a year-month-day date in the proleptic Julian calendar.

Trait Implementations§

Source§

impl<Representation: Clone, Period: Clone + ?Sized> Clone for ModifiedJulianDate<Representation, Period>

Source§

fn clone(&self) -> ModifiedJulianDate<Representation, Period>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Representation: Debug, Period: Debug + ?Sized> Debug for ModifiedJulianDate<Representation, Period>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Representation, Period: ?Sized> From<Date<Representation>> for ModifiedJulianDate<Representation, Period>
where Representation: Copy + From<i32> + Add<Representation, Output = Representation> + ConvertUnit<SecondsPerDay, Period>,

Source§

fn from(value: Date<Representation>) -> Self

Converts to this type from the input type.
Source§

impl<Representation, Period: ?Sized> From<ModifiedJulianDate<Representation, Period>> for Date<Representation>
where Representation: Copy + From<i32> + Sub<Representation, Output = Representation> + ConvertUnit<Period, SecondsPerDay>,

Source§

fn from(value: ModifiedJulianDate<Representation, Period>) -> Self

Converts to this type from the input type.
Source§

impl<Representation: Hash, Period: Hash + ?Sized> Hash for ModifiedJulianDate<Representation, Period>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Representation: Ord, Period: Ord + ?Sized> Ord for ModifiedJulianDate<Representation, Period>

Source§

fn cmp(&self, other: &ModifiedJulianDate<Representation, Period>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<Representation: PartialEq, Period: PartialEq + ?Sized> PartialEq for ModifiedJulianDate<Representation, Period>

Source§

fn eq(&self, other: &ModifiedJulianDate<Representation, Period>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Representation: PartialOrd, Period: PartialOrd + ?Sized> PartialOrd for ModifiedJulianDate<Representation, Period>

Source§

fn partial_cmp( &self, other: &ModifiedJulianDate<Representation, Period>, ) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<Representation: Copy, Period: Copy + ?Sized> Copy for ModifiedJulianDate<Representation, Period>

Source§

impl<Representation: Eq, Period: Eq + ?Sized> Eq for ModifiedJulianDate<Representation, Period>

Source§

impl<Representation, Period: ?Sized> StructuralPartialEq for ModifiedJulianDate<Representation, Period>

Auto Trait Implementations§

§

impl<Representation, Period> Freeze for ModifiedJulianDate<Representation, Period>
where Representation: Freeze, Period: ?Sized,

§

impl<Representation, Period> RefUnwindSafe for ModifiedJulianDate<Representation, Period>
where Representation: RefUnwindSafe, Period: RefUnwindSafe + ?Sized,

§

impl<Representation, Period> Send for ModifiedJulianDate<Representation, Period>
where Representation: Send, Period: Send + ?Sized,

§

impl<Representation, Period> Sync for ModifiedJulianDate<Representation, Period>
where Representation: Sync, Period: Sync + ?Sized,

§

impl<Representation, Period> Unpin for ModifiedJulianDate<Representation, Period>
where Representation: Unpin, Period: Unpin + ?Sized,

§

impl<Representation, Period> UnwindSafe for ModifiedJulianDate<Representation, Period>
where Representation: UnwindSafe, Period: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryIntoExact<T> for U
where T: TryFromExact<U>,

Source§

type Error = <T as TryFromExact<U>>::Error

Source§

fn try_into_exact(self) -> Result<T, <U as TryIntoExact<T>>::Error>

Tries to convert self into type T. If this conversion may succeed without loss of information, returns Ok(_) with the converted value. If any information may be lost (even if it is only floating point rounding), returns None.