Struct temporal_rs::components::Date
source · #[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>
impl<C: CalendarProtocol> Date<C>
sourcepub fn new(
year: i32,
month: i32,
day: i32,
calendar: CalendarSlot<C>,
overflow: ArithmeticOverflow
) -> TemporalResult<Self>
pub fn new( year: i32, month: i32, day: i32, calendar: CalendarSlot<C>, overflow: ArithmeticOverflow ) -> TemporalResult<Self>
Creates a new Date
while checking for validity.
sourcepub fn from_datetime(dt: &DateTime<C>) -> Self
pub fn from_datetime(dt: &DateTime<C>) -> Self
Creates a Date
from a DateTime
.
sourcepub fn calendar(&self) -> &CalendarSlot<C>
pub fn calendar(&self) -> &CalendarSlot<C>
Returns a reference to this Date
’s calendar slot.
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
3.5.7 IsValidISODate
Checks if the current date is a valid ISODate
.
sourcepub fn days_until(&self, other: &Self) -> i32
pub fn days_until(&self, other: &Self) -> i32
DaysUntil
Calculates the epoch days between two Date
s
source§impl Date<()>
impl Date<()>
sourcepub fn year(&self) -> TemporalResult<i32>
pub fn year(&self) -> TemporalResult<i32>
Returns the calendar year value.
sourcepub fn month(&self) -> TemporalResult<u8>
pub fn month(&self) -> TemporalResult<u8>
Returns the calendar month value.
sourcepub fn month_code(&self) -> TemporalResult<TinyAsciiStr<4>>
pub fn month_code(&self) -> TemporalResult<TinyAsciiStr<4>>
Returns the calendar month code value.
sourcepub fn day(&self) -> TemporalResult<u8>
pub fn day(&self) -> TemporalResult<u8>
Returns the calendar day value.
sourcepub fn day_of_week(&self) -> TemporalResult<u16>
pub fn day_of_week(&self) -> TemporalResult<u16>
Returns the calendar day of week value.
sourcepub fn day_of_year(&self) -> TemporalResult<u16>
pub fn day_of_year(&self) -> TemporalResult<u16>
Returns the calendar day of year value.
sourcepub fn week_of_year(&self) -> TemporalResult<u16>
pub fn week_of_year(&self) -> TemporalResult<u16>
Returns the calendar week of year value.
sourcepub fn year_of_week(&self) -> TemporalResult<i32>
pub fn year_of_week(&self) -> TemporalResult<i32>
Returns the calendar year of week value.
sourcepub fn days_in_week(&self) -> TemporalResult<u16>
pub fn days_in_week(&self) -> TemporalResult<u16>
Returns the calendar days in week value.
sourcepub fn days_in_month(&self) -> TemporalResult<u16>
pub fn days_in_month(&self) -> TemporalResult<u16>
Returns the calendar days in month value.
sourcepub fn days_in_year(&self) -> TemporalResult<u16>
pub fn days_in_year(&self) -> TemporalResult<u16>
Returns the calendar days in year value.
sourcepub fn months_in_year(&self) -> TemporalResult<u16>
pub fn months_in_year(&self) -> TemporalResult<u16>
Returns the calendar months in year value.
sourcepub fn in_leap_year(&self) -> TemporalResult<bool>
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>
impl<C: CalendarProtocol> Date<C>
sourcepub fn contextual_year(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<i32>
pub fn contextual_year( this: &C::Date, context: &mut C::Context ) -> TemporalResult<i32>
Returns the calendar year value with provided context.
sourcepub fn contextual_month(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u8>
pub fn contextual_month( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u8>
Returns the calendar month value with provided context.
sourcepub fn contextual_month_code(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<TinyAsciiStr<4>>
pub fn contextual_month_code( this: &C::Date, context: &mut C::Context ) -> TemporalResult<TinyAsciiStr<4>>
Returns the calendar month code value with provided context.
sourcepub fn contextual_day(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u8>
pub fn contextual_day( this: &C::Date, context: &mut C::Context ) -> TemporalResult<u8>
Returns the calendar day value with provided context.
sourcepub fn contextual_day_of_week(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u16>
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.
sourcepub fn contextual_day_of_year(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u16>
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.
sourcepub fn contextual_week_of_year(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u16>
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.
sourcepub fn contextual_year_of_week(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<i32>
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.
sourcepub fn contextual_days_in_week(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u16>
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.
sourcepub fn contextual_days_in_month(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u16>
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.
sourcepub fn contextual_days_in_year(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u16>
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.
sourcepub fn contextual_months_in_year(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<u16>
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.
sourcepub fn contextual_in_leap_year(
this: &C::Date,
context: &mut C::Context
) -> TemporalResult<bool>
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>
impl<C: CalendarProtocol> Date<C>
sourcepub fn contextual_add_date(
&self,
duration: &Duration,
overflow: ArithmeticOverflow,
context: &mut C::Context
) -> TemporalResult<Self>
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 ] ] )
sourcepub fn contextual_difference_date(
&self,
other: &Self,
largest_unit: TemporalUnit,
context: &mut C::Context
) -> TemporalResult<Duration>
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: CalendarProtocol> FromStr for Date<C>
impl<C: CalendarProtocol> FromStr for Date<C>
source§impl<C: CalendarProtocol> GetCalendarSlot<C> for Date<C>
impl<C: CalendarProtocol> GetCalendarSlot<C> for Date<C>
source§fn get_calendar(&self) -> CalendarSlot<C>
fn get_calendar(&self) -> CalendarSlot<C>
CalendarSlot<C>
value of the implementor.