#[non_exhaustive]
pub struct Date<C: CalendarProtocol> { /* private fields */ }
Expand description

The native Rust implementation of Temporal.PlainDate.

Implementations§

source§

impl<C: CalendarProtocol> Date<C>

source

pub fn new( year: i32, month: i32, day: i32, calendar: CalendarSlot<C>, overflow: ArithmeticOverflow ) -> TemporalResult<Self>

Creates a new Date while checking for validity.

source

pub fn from_datetime(dt: &DateTime<C>) -> Self

Creates a Date from a DateTime.

source

pub const fn iso_year(&self) -> i32

Returns this Date’s ISO year value.

source

pub const fn iso_month(&self) -> u8

Returns this Date’s ISO month value.

source

pub const fn iso_day(&self) -> u8

Returns this Date’s ISO day value.

source

pub fn calendar(&self) -> &CalendarSlot<C>

Returns a reference to this Date’s calendar slot.

source

pub fn is_valid(&self) -> bool

3.5.7 IsValidISODate

Checks if the current date is a valid ISODate.

source

pub fn days_until(&self, other: &Self) -> i32

DaysUntil

Calculates the epoch days between two Dates

source§

impl Date<()>

source

pub fn year(&self) -> TemporalResult<i32>

Returns the calendar year value.

source

pub fn month(&self) -> TemporalResult<u8>

Returns the calendar month value.

source

pub fn month_code(&self) -> TemporalResult<TinyAsciiStr<4>>

Returns the calendar month code value.

source

pub fn day(&self) -> TemporalResult<u8>

Returns the calendar day value.

source

pub fn day_of_week(&self) -> TemporalResult<u16>

Returns the calendar day of week value.

source

pub fn day_of_year(&self) -> TemporalResult<u16>

Returns the calendar day of year value.

source

pub fn week_of_year(&self) -> TemporalResult<u16>

Returns the calendar week of year value.

source

pub fn year_of_week(&self) -> TemporalResult<i32>

Returns the calendar year of week value.

source

pub fn days_in_week(&self) -> TemporalResult<u16>

Returns the calendar days in week value.

source

pub fn days_in_month(&self) -> TemporalResult<u16>

Returns the calendar days in month value.

source

pub fn days_in_year(&self) -> TemporalResult<u16>

Returns the calendar days in year value.

source

pub fn months_in_year(&self) -> TemporalResult<u16>

Returns the calendar months in year value.

source

pub fn in_leap_year(&self) -> TemporalResult<bool>

Returns returns whether the date in a leap year for the given calendar.

source§

impl<C: CalendarProtocol> Date<C>

source

pub fn contextual_year( this: &C::Date, context: &mut C::Context ) -> TemporalResult<i32>

Returns the calendar year value with provided context.

source

pub fn contextual_month( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u8>

Returns the calendar month value with provided context.

source

pub fn contextual_month_code( this: &C::Date, context: &mut C::Context ) -> TemporalResult<TinyAsciiStr<4>>

Returns the calendar month code value with provided context.

source

pub fn contextual_day( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u8>

Returns the calendar day value with provided context.

source

pub fn contextual_day_of_week( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u16>

Returns the calendar day of week value with provided context.

source

pub fn contextual_day_of_year( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u16>

Returns the calendar day of year value with provided context.

source

pub fn contextual_week_of_year( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u16>

Returns the calendar week of year value with provided context.

source

pub fn contextual_year_of_week( this: &C::Date, context: &mut C::Context ) -> TemporalResult<i32>

Returns the calendar year of week value with provided context.

source

pub fn contextual_days_in_week( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u16>

Returns the calendar days in week value with provided context.

source

pub fn contextual_days_in_month( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u16>

Returns the calendar days in month value with provided context.

source

pub fn contextual_days_in_year( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u16>

Returns the calendar days in year value with provided context.

source

pub fn contextual_months_in_year( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u16>

Returns the calendar months in year value with provided context.

source

pub fn contextual_in_leap_year( this: &C::Date, context: &mut C::Context ) -> TemporalResult<bool>

Returns whether the date is in a leap year for the given calendar with provided context.

source§

impl<C: CalendarProtocol> Date<C>

source

pub fn contextual_add_date( &self, duration: &Duration, overflow: ArithmeticOverflow, context: &mut C::Context ) -> TemporalResult<Self>

Returns the date after adding the given duration to date with a provided context.

Temporal Equivalent: 3.5.13 AddDate ( calendar, plainDate, duration [ , options [ , dateAdd ] ] )

source

pub fn contextual_difference_date( &self, other: &Self, largest_unit: TemporalUnit, context: &mut C::Context ) -> TemporalResult<Duration>

Returns a duration representing the difference between the dates one and two with a provided context.

Temporal Equivalent: 3.5.6 DifferenceDate ( calendar, one, two, options )

Trait Implementations§

source§

impl<C: Clone + CalendarProtocol> Clone for Date<C>

source§

fn clone(&self) -> Date<C>

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: Debug + CalendarProtocol> Debug for Date<C>

source§

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

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

impl<C: Default + CalendarProtocol> Default for Date<C>

source§

fn default() -> Date<C>

Returns the “default value” for a type. Read more
source§

impl<C: CalendarProtocol> FromStr for Date<C>

§

type Err = TemporalError

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

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl<C: CalendarProtocol> GetCalendarSlot<C> for Date<C>

source§

fn get_calendar(&self) -> CalendarSlot<C>

Returns the CalendarSlot<C> value of the implementor.
source§

impl<C: CalendarProtocol> IsoDateSlots for Date<C>

source§

fn iso_date(&self) -> IsoDate

Returns the structs IsoDate

Auto Trait Implementations§

§

impl<C> RefUnwindSafe for Date<C>
where C: RefUnwindSafe,

§

impl<C> !Send for Date<C>

§

impl<C> !Sync for Date<C>

§

impl<C> Unpin for Date<C>
where C: Unpin,

§

impl<C> UnwindSafe for Date<C>
where C: UnwindSafe,

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> 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,

§

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>,

§

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>,

§

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