Trait CalendarDate

Source
pub trait CalendarDate: Sized + Display {
    const MIN: Self;
    const MAX: Self;

    // Required methods
    fn as_julian(&self) -> i32;
    fn from_julian(value: i32) -> Option<Self>;

    // Provided methods
    fn tomorrow(self) -> Option<Self> { ... }
    fn yesterday(self) -> Option<Self> { ... }
    fn convert<T: CalendarDate>(self) -> T { ... }
}
Expand description

A minimum set of functionality a typical calendar should provide.

Required Associated Constants§

Source

const MIN: Self

Earliest representable date.

Source

const MAX: Self

Latest representable date.

Required Methods§

Source

fn as_julian(&self) -> i32

Convert the date into the corresponding Julian Day Number.

Source

fn from_julian(value: i32) -> Option<Self>

Get the date from the corresponding Julian

Provided Methods§

Source

fn tomorrow(self) -> Option<Self>

Source

fn yesterday(self) -> Option<Self>

Source

fn convert<T: CalendarDate>(self) -> T

Converts the calendar date to a different calendar system.

§Examples
use sac13::prelude::*;
use sac13::day_counts::*;

let date_sac13 : Date = JulianDay::new(2460000).unwrap().convert();
let date_greg : GregorianDate = date_sac13.convert();

It’s basically like the From trait, but because of the orphan rule I failed to implement it generically for all types that implement CalendarDate.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl CalendarDate for CycleEpochDay

Source§

const MIN: Self = Self::MIN

Source§

const MAX: Self = Self::MAX

Source§

impl CalendarDate for JulianDay

Source§

const MIN: Self = Self::MIN

Source§

const MAX: Self = Self::MAX

Source§

impl CalendarDate for Sac13Day

Source§

const MIN: Self = Self::MIN

Source§

const MAX: Self = Self::MAX

Source§

impl CalendarDate for UnixDay

Source§

const MIN: Self = Self::MIN

Source§

const MAX: Self = Self::MAX

Source§

impl CalendarDate for YearOrdinal

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl CalendarDate for Date

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl CalendarDate for GregorianDate

Source§

const MIN: Self = Self::MIN

Source§

const MAX: Self = Self::MAX