Struct icu_calendar::DateTime

source ·
pub struct DateTime<A: AsCalendar> {
    pub date: Date<A>,
    pub time: Time,
}
Expand description

A date+time for a given calendar.

This can work with wrappers around Calendar types, e.g. Rc<C>, via the AsCalendar trait, much like Date.

This can be constructed manually from a Date and Time, or can be constructed from its fields via Self::try_new_from_codes(), or can be constructed with one of the new_<calendar>_datetime() per-calendar methods (and then freely converted between calendars).

use icu::calendar::DateTime;

// Example: Construction of ISO datetime from integers.
let datetime_iso = DateTime::try_new_iso_datetime(1970, 1, 2, 13, 1, 0)
    .expect("Failed to initialize ISO DateTime instance.");

assert_eq!(datetime_iso.date.year().number, 1970);
assert_eq!(datetime_iso.date.month().ordinal, 1);
assert_eq!(datetime_iso.date.day_of_month().0, 2);
assert_eq!(datetime_iso.time.hour.number(), 13);
assert_eq!(datetime_iso.time.minute.number(), 1);
assert_eq!(datetime_iso.time.second.number(), 0);

Fields§

§date: Date<A>

The date

§time: Time

The time

Implementations§

source§

impl<A: AsCalendar> DateTime<A>

source

pub fn new(date: Date<A>, time: Time) -> Self

Construct a DateTime for a given Date and Time

source

pub fn try_new_from_codes( era: Era, year: i32, month_code: MonthCode, day: u8, time: Time, calendar: A, ) -> Result<Self, CalendarError>

Construct a datetime from from era/month codes and fields, and some calendar representation

source

pub fn new_from_iso(iso: DateTime<Iso>, calendar: A) -> Self

Construct a DateTime from an ISO datetime and some calendar representation

source

pub fn to_iso(&self) -> DateTime<Iso>

Convert the DateTime to an ISO DateTime

source

pub fn to_calendar<A2: AsCalendar>(&self, calendar: A2) -> DateTime<A2>

Convert the DateTime to a DateTime in a different calendar

source§

impl<C: IntoAnyCalendar, A: AsCalendar<Calendar = C>> DateTime<A>

source

pub fn to_any(&self) -> DateTime<AnyCalendar>

Type-erase the date, converting it to a date for AnyCalendar

source§

impl<C: Calendar> DateTime<C>

source

pub fn wrap_calendar_in_rc(self) -> DateTime<Rc<C>>

Wrap the calendar type in Rc<T>

Useful when paired with Self::to_any() to obtain a DateTime<Rc<AnyCalendar>>

source

pub fn wrap_calendar_in_arc(self) -> DateTime<Arc<C>>

Wrap the calendar type in Arc<T>

Useful when paired with Self::to_any() to obtain a DateTime<Rc<AnyCalendar>>

source§

impl DateTime<Buddhist>

source

pub fn try_new_buddhist_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Buddhist>, CalendarError>

Construct a new Buddhist datetime from integers.

Years are specified as BE years.

use icu::calendar::DateTime;

let datetime_buddhist =
    DateTime::try_new_buddhist_datetime(1970, 1, 2, 13, 1, 0)
        .expect("Failed to initialize Buddhist DateTime instance.");

assert_eq!(datetime_buddhist.date.year().number, 1970);
assert_eq!(datetime_buddhist.date.month().ordinal, 1);
assert_eq!(datetime_buddhist.date.day_of_month().0, 2);
assert_eq!(datetime_buddhist.time.hour.number(), 13);
assert_eq!(datetime_buddhist.time.minute.number(), 1);
assert_eq!(datetime_buddhist.time.second.number(), 0);
source§

impl<A: AsCalendar<Calendar = Chinese>> DateTime<A>

source

pub fn try_new_chinese_datetime_with_calendar( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, calendar: A, ) -> Result<DateTime<A>, CalendarError>

Construct a new Chinese datetime from integers using the -2636-based year system

This datetime will not use any precomputed calendrical calculations, one that loads such data from a provider will be added in the future (#3933)

use icu::calendar::{chinese::Chinese, DateTime};

let chinese = Chinese::new_always_calculating();

let chinese_datetime = DateTime::try_new_chinese_datetime_with_calendar(
    4660, 6, 11, 13, 1, 0, chinese,
)
.expect("Failed to initialize Chinese DateTime instance.");

assert_eq!(chinese_datetime.date.year().number, 4660);
assert_eq!(chinese_datetime.date.year().related_iso, Some(2023));
assert_eq!(chinese_datetime.date.year().cyclic.unwrap().get(), 40);
assert_eq!(chinese_datetime.date.month().ordinal, 6);
assert_eq!(chinese_datetime.date.day_of_month().0, 11);
assert_eq!(chinese_datetime.time.hour.number(), 13);
assert_eq!(chinese_datetime.time.minute.number(), 1);
assert_eq!(chinese_datetime.time.second.number(), 0);
source§

impl DateTime<Coptic>

source

pub fn try_new_coptic_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Coptic>, CalendarError>

Construct a new Coptic datetime from integers.

Negative years are in the B.D. era, starting with 0 = 1 B.D.

use icu::calendar::DateTime;

let datetime_coptic =
    DateTime::try_new_coptic_datetime(1686, 5, 6, 13, 1, 0)
        .expect("Failed to initialize Coptic DateTime instance.");

assert_eq!(datetime_coptic.date.year().number, 1686);
assert_eq!(datetime_coptic.date.month().ordinal, 5);
assert_eq!(datetime_coptic.date.day_of_month().0, 6);
assert_eq!(datetime_coptic.time.hour.number(), 13);
assert_eq!(datetime_coptic.time.minute.number(), 1);
assert_eq!(datetime_coptic.time.second.number(), 0);
source§

impl<A: AsCalendar<Calendar = Dangi>> DateTime<A>

source

pub fn try_new_dangi_datetime_with_calendar( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, calendar: A, ) -> Result<DateTime<A>, CalendarError>

Construct a new Dangi DateTime from integers. See try_new_dangi_date_with_calendar.

This datetime will not use any precomputed calendrical calculations, one that loads such data from a provider will be added in the future (#3933)

use icu::calendar::dangi::Dangi;
use icu::calendar::DateTime;

let dangi = Dangi::new();

let dangi_datetime = DateTime::try_new_dangi_datetime_with_calendar(
    4356, 6, 6, 13, 1, 0, dangi,
)
.expect("Failed to initialize Dangi DateTime instance.");

assert_eq!(dangi_datetime.date.year().number, 4356);
assert_eq!(dangi_datetime.date.year().related_iso, Some(2023));
assert_eq!(dangi_datetime.date.year().cyclic.unwrap().get(), 40);
assert_eq!(dangi_datetime.date.month().ordinal, 6);
assert_eq!(dangi_datetime.date.day_of_month().0, 6);
assert_eq!(dangi_datetime.time.hour.number(), 13);
assert_eq!(dangi_datetime.time.minute.number(), 1);
assert_eq!(dangi_datetime.time.second.number(), 0);
source§

impl DateTime<Ethiopian>

source

pub fn try_new_ethiopian_datetime( era_style: EthiopianEraStyle, year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Ethiopian>, CalendarError>

Construct a new Ethiopian datetime from integers.

For the Amete Mihret era style, negative years work with year 0 as 1 pre-Incarnation, year -1 as 2 pre-Incarnation, and so on.

use icu::calendar::ethiopian::EthiopianEraStyle;
use icu::calendar::DateTime;

let datetime_ethiopian = DateTime::try_new_ethiopian_datetime(
    EthiopianEraStyle::AmeteMihret,
    2014,
    8,
    25,
    13,
    1,
    0,
)
.expect("Failed to initialize Ethiopian DateTime instance.");

assert_eq!(datetime_ethiopian.date.year().number, 2014);
assert_eq!(datetime_ethiopian.date.month().ordinal, 8);
assert_eq!(datetime_ethiopian.date.day_of_month().0, 25);
assert_eq!(datetime_ethiopian.time.hour.number(), 13);
assert_eq!(datetime_ethiopian.time.minute.number(), 1);
assert_eq!(datetime_ethiopian.time.second.number(), 0);
source§

impl DateTime<Gregorian>

source

pub fn try_new_gregorian_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Gregorian>, CalendarError>

Construct a new Gregorian datetime from integers.

Years are specified as ISO years.

use icu::calendar::DateTime;

let datetime_gregorian =
    DateTime::try_new_gregorian_datetime(1970, 1, 2, 13, 1, 0)
        .expect("Failed to initialize Gregorian DateTime instance.");

assert_eq!(datetime_gregorian.date.year().number, 1970);
assert_eq!(datetime_gregorian.date.month().ordinal, 1);
assert_eq!(datetime_gregorian.date.day_of_month().0, 2);
assert_eq!(datetime_gregorian.time.hour.number(), 13);
assert_eq!(datetime_gregorian.time.minute.number(), 1);
assert_eq!(datetime_gregorian.time.second.number(), 0);
source§

impl DateTime<Hebrew>

source

pub fn try_new_hebrew_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Hebrew>, CalendarError>

Construct a new Hebrew datetime from integers.

use icu::calendar::DateTime;

let datetime_hebrew =
    DateTime::try_new_hebrew_datetime(4201, 10, 11, 13, 1, 0)
        .expect("Failed to initialize Hebrew DateTime instance");

assert_eq!(datetime_hebrew.date.year().number, 4201);
assert_eq!(datetime_hebrew.date.month().ordinal, 10);
assert_eq!(datetime_hebrew.date.day_of_month().0, 11);
assert_eq!(datetime_hebrew.time.hour.number(), 13);
assert_eq!(datetime_hebrew.time.minute.number(), 1);
assert_eq!(datetime_hebrew.time.second.number(), 0);
source§

impl<A: AsCalendar<Calendar = Hebrew>> DateTime<A>

source

pub fn try_new_hebrew_datetime_with_calendar( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, calendar: A, ) -> Result<DateTime<A>, CalendarError>

👎Deprecated since 1.5.0: Use DateTime::try_new_hebrew_datetime()

Construct new Hebrew DateTime given a calendar.

This is deprecated since Hebrew is a zero-sized type, but if you find yourself needing this functionality please let us know.

source§

impl DateTime<Indian>

source

pub fn try_new_indian_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Indian>, CalendarError>

Construct a new Indian datetime from integers, with year provided in the Śaka era.

use icu::calendar::DateTime;

let datetime_indian =
    DateTime::try_new_indian_datetime(1891, 10, 12, 13, 1, 0)
        .expect("Failed to initialize Indian DateTime instance.");

assert_eq!(datetime_indian.date.year().number, 1891);
assert_eq!(datetime_indian.date.month().ordinal, 10);
assert_eq!(datetime_indian.date.day_of_month().0, 12);
assert_eq!(datetime_indian.time.hour.number(), 13);
assert_eq!(datetime_indian.time.minute.number(), 1);
assert_eq!(datetime_indian.time.second.number(), 0);
source§

impl<A: AsCalendar<Calendar = IslamicObservational>> DateTime<A>

source

pub fn try_new_observational_islamic_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, calendar: A, ) -> Result<DateTime<A>, CalendarError>

Construct a new Islamic Observational datetime from integers.

use icu::calendar::islamic::IslamicObservational;
use icu::calendar::DateTime;

let islamic = IslamicObservational::new_always_calculating();

let datetime_islamic = DateTime::try_new_observational_islamic_datetime(
    474, 10, 11, 13, 1, 0, islamic,
)
.expect("Failed to initialize Islamic DateTime instance.");

assert_eq!(datetime_islamic.date.year().number, 474);
assert_eq!(datetime_islamic.date.month().ordinal, 10);
assert_eq!(datetime_islamic.date.day_of_month().0, 11);
assert_eq!(datetime_islamic.time.hour.number(), 13);
assert_eq!(datetime_islamic.time.minute.number(), 1);
assert_eq!(datetime_islamic.time.second.number(), 0);
source§

impl<A: AsCalendar<Calendar = IslamicUmmAlQura>> DateTime<A>

source

pub fn try_new_ummalqura_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, calendar: A, ) -> Result<DateTime<A>, CalendarError>

Construct a new Islamic Umm al-Qura datetime from integers.

use icu::calendar::islamic::IslamicUmmAlQura;
use icu::calendar::DateTime;

let islamic = IslamicUmmAlQura::new_always_calculating();

let datetime_islamic =
    DateTime::try_new_ummalqura_datetime(474, 10, 11, 13, 1, 0, islamic)
        .expect("Failed to initialize Islamic DateTime instance.");

assert_eq!(datetime_islamic.date.year().number, 474);
assert_eq!(datetime_islamic.date.month().ordinal, 10);
assert_eq!(datetime_islamic.date.day_of_month().0, 11);
assert_eq!(datetime_islamic.time.hour.number(), 13);
assert_eq!(datetime_islamic.time.minute.number(), 1);
assert_eq!(datetime_islamic.time.second.number(), 0);
source§

impl<A: AsCalendar<Calendar = IslamicCivil>> DateTime<A>

source

pub fn try_new_islamic_civil_datetime_with_calendar( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, calendar: A, ) -> Result<DateTime<A>, CalendarError>

Construct a new Civil Islamic datetime from integers.

use icu::calendar::islamic::IslamicCivil;
use icu::calendar::DateTime;

let islamic = IslamicCivil::new_always_calculating();

let datetime_islamic =
    DateTime::try_new_islamic_civil_datetime_with_calendar(
        474, 10, 11, 13, 1, 0, islamic,
    )
    .expect("Failed to initialize Islamic DateTime instance.");

assert_eq!(datetime_islamic.date.year().number, 474);
assert_eq!(datetime_islamic.date.month().ordinal, 10);
assert_eq!(datetime_islamic.date.day_of_month().0, 11);
assert_eq!(datetime_islamic.time.hour.number(), 13);
assert_eq!(datetime_islamic.time.minute.number(), 1);
assert_eq!(datetime_islamic.time.second.number(), 0);
source§

impl<A: AsCalendar<Calendar = IslamicTabular>> DateTime<A>

source

pub fn try_new_islamic_tabular_datetime_with_calendar( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, calendar: A, ) -> Result<DateTime<A>, CalendarError>

Construct a new Tabular Islamic datetime from integers.

use icu::calendar::islamic::IslamicTabular;
use icu::calendar::DateTime;

let islamic = IslamicTabular::new_always_calculating();

let datetime_islamic =
    DateTime::try_new_islamic_tabular_datetime_with_calendar(
        474, 10, 11, 13, 1, 0, islamic,
    )
    .expect("Failed to initialize Islamic DateTime instance.");

assert_eq!(datetime_islamic.date.year().number, 474);
assert_eq!(datetime_islamic.date.month().ordinal, 10);
assert_eq!(datetime_islamic.date.day_of_month().0, 11);
assert_eq!(datetime_islamic.time.hour.number(), 13);
assert_eq!(datetime_islamic.time.minute.number(), 1);
assert_eq!(datetime_islamic.time.second.number(), 0);
source§

impl DateTime<Iso>

source

pub fn try_new_iso_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Iso>, CalendarError>

Construct a new ISO datetime from integers.

use icu::calendar::DateTime;

let datetime_iso = DateTime::try_new_iso_datetime(1970, 1, 2, 13, 1, 0)
    .expect("Failed to initialize ISO DateTime instance.");

assert_eq!(datetime_iso.date.year().number, 1970);
assert_eq!(datetime_iso.date.month().ordinal, 1);
assert_eq!(datetime_iso.date.day_of_month().0, 2);
assert_eq!(datetime_iso.time.hour.number(), 13);
assert_eq!(datetime_iso.time.minute.number(), 1);
assert_eq!(datetime_iso.time.second.number(), 0);
source

pub fn local_unix_epoch() -> Self

Constructs an ISO datetime representing the UNIX epoch on January 1, 1970 at midnight.

source

pub fn minutes_since_local_unix_epoch(&self) -> i32

Minute count representation of calendars starting from 00:00:00 on Jan 1st, 1970.

use icu::calendar::DateTime;

let today = DateTime::try_new_iso_datetime(2020, 2, 29, 0, 0, 0).unwrap();

assert_eq!(today.minutes_since_local_unix_epoch(), 26382240);
assert_eq!(
    DateTime::from_minutes_since_local_unix_epoch(26382240),
    today
);

let today = DateTime::try_new_iso_datetime(1970, 1, 1, 0, 0, 0).unwrap();

assert_eq!(today.minutes_since_local_unix_epoch(), 0);
assert_eq!(DateTime::from_minutes_since_local_unix_epoch(0), today);
source

pub fn from_minutes_since_local_unix_epoch(minute: i32) -> DateTime<Iso>

Convert minute count since 00:00:00 on Jan 1st, 1970 to ISO Date.

§Examples
use icu::calendar::DateTime;

// After Unix Epoch
let today = DateTime::try_new_iso_datetime(2020, 2, 29, 0, 0, 0).unwrap();

assert_eq!(today.minutes_since_local_unix_epoch(), 26382240);
assert_eq!(
    DateTime::from_minutes_since_local_unix_epoch(26382240),
    today
);

// Unix Epoch
let today = DateTime::try_new_iso_datetime(1970, 1, 1, 0, 0, 0).unwrap();

assert_eq!(today.minutes_since_local_unix_epoch(), 0);
assert_eq!(DateTime::from_minutes_since_local_unix_epoch(0), today);

// Before Unix Epoch
let today = DateTime::try_new_iso_datetime(1967, 4, 6, 20, 40, 0).unwrap();

assert_eq!(today.minutes_since_local_unix_epoch(), -1440200);
assert_eq!(
    DateTime::from_minutes_since_local_unix_epoch(-1440200),
    today
);
source§

impl DateTime<Japanese>

source

pub fn try_new_japanese_datetime<A: AsCalendar<Calendar = Japanese>>( era: Era, year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, japanese_calendar: A, ) -> Result<DateTime<A>, CalendarError>

Construct a new Japanese datetime from integers.

Years are specified in the era provided.

use icu::calendar::japanese::Japanese;
use icu::calendar::{types, DateTime};
use tinystr::tinystr;

let japanese_calendar = Japanese::new();

let era = types::Era(tinystr!(16, "heisei"));

let datetime = DateTime::try_new_japanese_datetime(
    era,
    14,
    1,
    2,
    13,
    1,
    0,
    japanese_calendar,
)
.expect("Constructing a date should succeed");

assert_eq!(datetime.date.year().era, era);
assert_eq!(datetime.date.year().number, 14);
assert_eq!(datetime.date.month().ordinal, 1);
assert_eq!(datetime.date.day_of_month().0, 2);
assert_eq!(datetime.time.hour.number(), 13);
assert_eq!(datetime.time.minute.number(), 1);
assert_eq!(datetime.time.second.number(), 0);
source§

impl DateTime<JapaneseExtended>

source

pub fn try_new_japanese_extended_datetime<A: AsCalendar<Calendar = JapaneseExtended>>( era: Era, year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, japanext_calendar: A, ) -> Result<DateTime<A>, CalendarError>

Construct a new Japanese datetime from integers with all eras.

Years are specified in the era provided.

use icu::calendar::japanese::JapaneseExtended;
use icu::calendar::{types, DateTime};
use tinystr::tinystr;

let japanext_calendar = JapaneseExtended::new();

let era = types::Era(tinystr!(16, "kansei-1789"));

let datetime = DateTime::try_new_japanese_extended_datetime(
    era,
    7,
    1,
    2,
    13,
    1,
    0,
    japanext_calendar,
)
.expect("Constructing a date should succeed");

assert_eq!(datetime.date.year().era, era);
assert_eq!(datetime.date.year().number, 7);
assert_eq!(datetime.date.month().ordinal, 1);
assert_eq!(datetime.date.day_of_month().0, 2);
assert_eq!(datetime.time.hour.number(), 13);
assert_eq!(datetime.time.minute.number(), 1);
assert_eq!(datetime.time.second.number(), 0);
source§

impl DateTime<Julian>

source

pub fn try_new_julian_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Julian>, CalendarError>

Construct a new Julian datetime from integers.

Years are arithmetic, meaning there is a year 0. Zero and negative years are in BC, with year 0 = 1 BC

use icu::calendar::DateTime;

let datetime_julian =
    DateTime::try_new_julian_datetime(1969, 12, 20, 13, 1, 0)
        .expect("Failed to initialize Julian DateTime instance.");

assert_eq!(datetime_julian.date.year().number, 1969);
assert_eq!(datetime_julian.date.month().ordinal, 12);
assert_eq!(datetime_julian.date.day_of_month().0, 20);
assert_eq!(datetime_julian.time.hour.number(), 13);
assert_eq!(datetime_julian.time.minute.number(), 1);
assert_eq!(datetime_julian.time.second.number(), 0);
source§

impl DateTime<Persian>

source

pub fn try_new_persian_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Persian>, CalendarError>

Construct a new Persian datetime from integers.

use icu::calendar::DateTime;

let datetime_persian =
    DateTime::try_new_persian_datetime(474, 10, 11, 13, 1, 0)
        .expect("Failed to initialize Persian DateTime instance.");

assert_eq!(datetime_persian.date.year().number, 474);
assert_eq!(datetime_persian.date.month().ordinal, 10);
assert_eq!(datetime_persian.date.day_of_month().0, 11);
assert_eq!(datetime_persian.time.hour.number(), 13);
assert_eq!(datetime_persian.time.minute.number(), 1);
assert_eq!(datetime_persian.time.second.number(), 0);
source§

impl DateTime<Roc>

source

pub fn try_new_roc_datetime( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Roc>, CalendarError>

Construct a new Republic of China calendar datetime from integers.

Years are specified in the “roc” era, Before Minguo dates are negative (year 0 is 1 Before Minguo)

use icu::calendar::DateTime;
use tinystr::tinystr;

// Create a new ROC DateTime
let datetime_roc = DateTime::try_new_roc_datetime(1, 2, 3, 13, 1, 0)
    .expect("Failed to initialize ROC DateTime instance.");

assert_eq!(datetime_roc.date.year().era.0, tinystr!(16, "roc"));
assert_eq!(datetime_roc.date.year().number, 1, "ROC year check failed!");
assert_eq!(
    datetime_roc.date.month().ordinal,
    2,
    "ROC month check failed!"
);
assert_eq!(
    datetime_roc.date.day_of_month().0,
    3,
    "ROC day of month check failed!"
);
assert_eq!(datetime_roc.time.hour.number(), 13);
assert_eq!(datetime_roc.time.minute.number(), 1);
assert_eq!(datetime_roc.time.second.number(), 0);

Trait Implementations§

source§

impl<A: AsCalendar + Clone> Clone for DateTime<A>

source§

fn clone(&self) -> Self

Returns a copy 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<A: Debug + AsCalendar> Debug for DateTime<A>

source§

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

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

impl<C, A> Ord for DateTime<A>
where C: Calendar, C::DateInner: Ord, A: AsCalendar<Calendar = C>,

source§

fn cmp(&self, other: &Self) -> 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 + PartialOrd,

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

impl<C, A, B> PartialEq<DateTime<B>> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>, B: AsCalendar<Calendar = C>,

source§

fn eq(&self, other: &DateTime<B>) -> 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<C, A, B> PartialOrd<DateTime<B>> for DateTime<A>
where C: Calendar, C::DateInner: PartialOrd, A: AsCalendar<Calendar = C>, B: AsCalendar<Calendar = C>,

source§

fn partial_cmp(&self, other: &DateTime<B>) -> 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<A> Copy for DateTime<A>

source§

impl<A: AsCalendar> Eq for DateTime<A>

Auto Trait Implementations§

§

impl<A> Freeze for DateTime<A>

§

impl<A> RefUnwindSafe for DateTime<A>

§

impl<A> Send for DateTime<A>
where <<A as AsCalendar>::Calendar as Calendar>::DateInner: Send, A: Send,

§

impl<A> Sync for DateTime<A>
where <<A as AsCalendar>::Calendar as Calendar>::DateInner: Sync, A: Sync,

§

impl<A> Unpin for DateTime<A>
where <<A as AsCalendar>::Calendar as Calendar>::DateInner: Unpin, A: Unpin,

§

impl<A> UnwindSafe for DateTime<A>

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T