Struct icu::calendar::DateTime

source ·
pub struct DateTime<A>
where 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(1970, 1, 2, 13, 1, 0)
    .expect("Failed to initialize ISO DateTime instance.");

assert_eq!(datetime_iso.date.year().era_year_or_extended(), 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> DateTime<A>
where A: AsCalendar,

source

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

Construct a DateTime for a given Date and Time

source

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

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) -> DateTime<A>

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>(&self, calendar: A2) -> DateTime<A2>
where A2: AsCalendar,

Convert the DateTime to a DateTime in a different calendar

source§

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

source

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

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

source§

impl<C> DateTime<C>
where C: Calendar,

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( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Buddhist>, DateError>

Construct a new Buddhist datetime from integers.

Years are specified as BE years.

use icu::calendar::DateTime;

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

assert_eq!(datetime_buddhist.date.year().era_year_or_extended(), 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> DateTime<A>
where A: AsCalendar<Calendar = Chinese>,

source

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

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::{cal::Chinese, DateTime};

let chinese = Chinese::new_always_calculating();

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

assert_eq!(chinese_datetime.date.year().era_year_or_extended(), 4660);
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( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Coptic>, DateError>

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(1686, 5, 6, 13, 1, 0)
        .expect("Failed to initialize Coptic DateTime instance.");

assert_eq!(datetime_coptic.date.year().era_year_or_extended(), 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> DateTime<A>
where A: AsCalendar<Calendar = Dangi>,

source

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

Construct a new Dangi DateTime from integers. See try_new_dangi_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::cal::Dangi;
use icu::calendar::DateTime;

let dangi = Dangi::new();

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

assert_eq!(dangi_datetime.date.year().era_year_or_extended(), 4356);
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( era_style: EthiopianEraStyle, year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Ethiopian>, DateError>

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::cal::EthiopianEraStyle;
use icu::calendar::DateTime;

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

assert_eq!(datetime_ethiopian.date.year().era_year_or_extended(), 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( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Gregorian>, DateError>

Construct a new Gregorian datetime from integers.

Years are specified as ISO years.

use icu::calendar::DateTime;

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

assert_eq!(datetime_gregorian.date.year().era_year_or_extended(), 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( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Hebrew>, DateError>

Construct a new Hebrew datetime from integers.

use icu::calendar::DateTime;

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

assert_eq!(datetime_hebrew.date.year().era_year_or_extended(), 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 DateTime<Indian>

source

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

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(1891, 10, 12, 13, 1, 0)
        .expect("Failed to initialize Indian DateTime instance.");

assert_eq!(datetime_indian.date.year().era_year_or_extended(), 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> DateTime<A>
where A: AsCalendar<Calendar = IslamicObservational>,

source

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

Construct a new Islamic Observational datetime from integers.

use icu::calendar::cal::IslamicObservational;
use icu::calendar::DateTime;

let islamic = IslamicObservational::new_always_calculating();

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

assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 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> DateTime<A>
where A: AsCalendar<Calendar = IslamicUmmAlQura>,

source

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

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

use icu::calendar::cal::IslamicUmmAlQura;
use icu::calendar::DateTime;

let islamic = IslamicUmmAlQura::new_always_calculating();

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

assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 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> DateTime<A>
where A: AsCalendar<Calendar = IslamicCivil>,

source

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

Construct a new Civil Islamic datetime from integers.

use icu::calendar::cal::IslamicCivil;
use icu::calendar::DateTime;

let islamic = IslamicCivil::new();

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

assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 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> DateTime<A>
where A: AsCalendar<Calendar = IslamicTabular>,

source

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

Construct a new Tabular Islamic datetime from integers.

use icu::calendar::cal::IslamicTabular;
use icu::calendar::DateTime;

let islamic = IslamicTabular::new();

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

assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 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( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Iso>, DateError>

Construct a new ISO datetime from integers.

use icu::calendar::DateTime;

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

assert_eq!(datetime_iso.date.year().era_year_or_extended(), 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§

impl DateTime<Iso>

source

pub fn try_iso_from_str(ixdtf_str: &str) -> Result<DateTime<Iso>, ParseError>

Creates a DateTime in the ISO-8601 calendar from an IXDTF syntax string.

Ignores any calendar annotations in the string.

Enabled with the ixdtf Cargo feature.

§Examples
use icu::calendar::DateTime;

let datetime = DateTime::try_iso_from_str("2024-07-17T16:01:17.045").unwrap();

assert_eq!(datetime.date.year().era_year_or_extended(), 2024);
assert_eq!(
    datetime.date.month().standard_code,
    icu::calendar::types::MonthCode(tinystr::tinystr!(4, "M07"))
);
assert_eq!(datetime.date.day_of_month().0, 17);

assert_eq!(datetime.time.hour.number(), 16);
assert_eq!(datetime.time.minute.number(), 1);
assert_eq!(datetime.time.second.number(), 17);
assert_eq!(datetime.time.nanosecond.number(), 45000000);
source

pub fn try_iso_from_utf8(ixdtf_str: &[u8]) -> Result<DateTime<Iso>, ParseError>

Creates a DateTime in the ISO-8601 calendar from an IXDTF syntax string.

Enabled with the ixdtf Cargo feature.

See Self::try_iso_from_str().

source§

impl DateTime<AnyCalendar>

source

pub fn try_from_str( ixdtf_str: &str, ) -> Result<DateTime<AnyCalendar>, ParseError>

Creates a DateTime in any calendar from an IXDTF syntax string with compiled data.

Enabled with the compiled_data and ixdtf Cargo features.

§Examples
use icu::calendar::DateTime;

let datetime = DateTime::try_from_str("2024-07-17T16:01:17.045[u-ca=hebrew]").unwrap();

assert_eq!(datetime.date.year().era_year_or_extended(), 5784);
assert_eq!(
    datetime.date.month().standard_code,
    icu::calendar::types::MonthCode(tinystr::tinystr!(4, "M10"))
);
assert_eq!(datetime.date.day_of_month().0, 11);

assert_eq!(datetime.time.hour.number(), 16);
assert_eq!(datetime.time.minute.number(), 1);
assert_eq!(datetime.time.second.number(), 17);
assert_eq!(datetime.time.nanosecond.number(), 45000000);
source

pub fn try_from_utf8( ixdtf_str: &[u8], ) -> Result<DateTime<AnyCalendar>, ParseError>

Creates a DateTime in any calendar from an IXDTF syntax string with compiled data.

See Self::try_from_str().

Enabled with the compiled_data and ixdtf Cargo features.

source§

impl DateTime<Japanese>

source

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

Construct a new Japanese datetime from integers.

Years are specified in the era provided.

use icu::calendar::cal::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_with_calendar(
    era,
    14,
    1,
    2,
    13,
    1,
    0,
    japanese_calendar,
)
.expect("Constructing a date should succeed");

assert_eq!(datetime.date.year().standard_era().unwrap(), era);
assert_eq!(datetime.date.year().era_year_or_extended(), 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_with_calendar<A>( era: Era, year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, japanext_calendar: A, ) -> Result<DateTime<A>, DateError>
where A: AsCalendar<Calendar = JapaneseExtended>,

Construct a new Japanese datetime from integers with all eras.

Years are specified in the era provided.

use icu::calendar::cal::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_with_calendar(
    era,
    7,
    1,
    2,
    13,
    1,
    0,
    japanext_calendar,
)
.expect("Constructing a date should succeed");

assert_eq!(datetime.date.year().standard_era().unwrap(), era);
assert_eq!(datetime.date.year().era_year_or_extended(), 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( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Julian>, DateError>

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(1969, 12, 20, 13, 1, 0)
        .expect("Failed to initialize Julian DateTime instance.");

assert_eq!(datetime_julian.date.year().era_year_or_extended(), 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( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Persian>, DateError>

Construct a new Persian datetime from integers.

use icu::calendar::DateTime;

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

assert_eq!(datetime_persian.date.year().era_year_or_extended(), 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( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<DateTime<Roc>, DateError>

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(1, 2, 3, 13, 1, 0)
    .expect("Failed to initialize ROC DateTime instance.");

assert_eq!(datetime_roc.date.year().standard_era().unwrap().0, tinystr!(16, "roc"));
assert_eq!(datetime_roc.date.year().era_year_or_extended(), 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> Clone for DateTime<A>
where A: AsCalendar + Clone,

source§

fn clone(&self) -> DateTime<A>

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<C, A> ConvertCalendar for DateTime<A>
where C: IntoAnyCalendar, A: AsCalendar<Calendar = C>,

source§

type Converted<'a> = DateTime<Ref<'a, AnyCalendar>>

The converted type. This can be the same as the receiver type.
source§

fn to_calendar<'a>( &self, calendar: &'a AnyCalendar, ) -> <DateTime<A> as ConvertCalendar>::Converted<'a>

Converts self to the specified AnyCalendar.
source§

impl<A> Debug for DateTime<A>
where A: Debug + AsCalendar,

source§

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

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

impl FromStr for DateTime<AnyCalendar>

source§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str( ixdtf_str: &str, ) -> Result<DateTime<AnyCalendar>, <DateTime<AnyCalendar> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl FromStr for DateTime<Iso>

source§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str( ixdtf_str: &str, ) -> Result<DateTime<Iso>, <DateTime<Iso> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl<C, A> GetField<()> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self)

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<DayOfMonth> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> DayOfMonth

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<DayOfYearInfo> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> DayOfYearInfo

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<IsoHour> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> IsoHour

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<IsoMinute> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> IsoMinute

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<IsoSecond> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> IsoSecond

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<IsoWeekday> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> IsoWeekday

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<MonthInfo> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> MonthInfo

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<NanoSecond> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> NanoSecond

Returns the value of this trait’s field T.
source§

impl<C, A> GetField<YearInfo> for DateTime<A>
where C: Calendar, A: AsCalendar<Calendar = C>,

source§

fn get_field(&self) -> YearInfo

Returns the value of this trait’s field T.
source§

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

source§

fn check_any_calendar_kind( &self, any_calendar_kind: AnyCalendarKind, ) -> Result<(), MismatchedCalendarError>

Checks whether this type is compatible with the given calendar. Read more
source§

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

source§

fn cmp(&self, other: &DateTime<A>) -> 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 as Calendar>::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> Eq for DateTime<A>
where A: AsCalendar,

source§

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

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> GetField<T> for T
where T: Copy,

source§

fn get_field(&self) -> T

Returns the value of this trait’s field T.
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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
where T: Send + Sync,