[][src]Struct gregorian::Date

pub struct Date { /* fields omitted */ }

A calendar date consting of a year, month and day.

All dates in the library use the proleptic Gregorian calendar with a year 0.

Implementations

impl Date[src]

pub fn new<Y, M>(year: Y, month: M, day: u8) -> Result<Self, InvalidDate> where
    Y: Into<Year>,
    M: TryInto<Month>,
    InvalidDate: From<M::Error>, 
[src]

Create a new date from a year, month and day.

Month and day numbers start at 1.

pub const fn new_const(
    year: Year,
    month: Month,
    day: u8
) -> Result<Self, InvalidDayOfMonth>
[src]

Create a new date from a year, month and day.

Day numbers start at 1.

pub const unsafe fn new_unchecked(year: Year, month: Month, day: u8) -> Self[src]

Create a new date without checking the validity.

Month and day numbers start at 1.

Safety

Although this is currently not the case, future implementations may rely on date validity for memory safety

pub const fn from_unix_timestamp(seconds: i64) -> Self[src]

Get the date for a unix timestamp.

The timestamp is interpreted as number of seconds since 1 January 1970 00:00, not including any leap seconds.

pub const fn to_unix_timestamp(self) -> i64[src]

Get the unix timestamp for a date.

The timestamp is the number of seconds since 1 January 1970 00:00.

The returned timestamp is valid for time 00:00 of the date.

pub const fn year(self) -> Year[src]

Get the year.

pub const fn month(self) -> Month[src]

Get the month.

pub const fn day(self) -> u8[src]

Get the day of the month.

pub const fn year_month(self) -> YearMonth[src]

Get the year and month as YearMonth.

pub const fn day_of_year(self) -> u16[src]

Get the day of the year.

The returned number is 1-based. For January 1, this function will return 1.

pub const fn days_remaining_in_year(self) -> u16[src]

The number of days remaining in the year, including the current date.

For Janury 1 this will return 365 in a non-leap year or 366 in a leap year. For December 31, this will return 1.

pub const fn days_since_year_zero(self) -> i32[src]

Get the total number of days since 1 January 0000.

The returned value is zero-based. For 1 January 0000, this function returns 0.

pub const fn from_days_since_year_zero(days: i32) -> Self[src]

Get the date corresponding to a number of days since the year zero.

For this function, day 0 is 1 January of year 0.

pub const fn next(self) -> Date[src]

Get a Date object for the next day.

pub const fn prev(self) -> Date[src]

Get a Date object for the previous day.

pub const fn add_days(self, days: i32) -> Self[src]

Compute a date by adding days.

pub const fn sub_days(self, days: i32) -> Self[src]

Compute a date by subtracting days.

pub const fn add_months(self, months: i32) -> Result<Self, InvalidDayOfMonth>[src]

Compute a date by adding a number of months.

The resulting date may not be valid. You can call InvalidDayOfMonth::next_valid() or InvalidDayOfMonth::prev_valid() to get the first day of the next month or the last day of resulting month.

pub const fn sub_months(self, months: i32) -> Result<Self, InvalidDayOfMonth>[src]

Compute a date by subtracting a number of months.

The resulting date may not be valid. You can call InvalidDayOfMonth::next_valid() or InvalidDayOfMonth::prev_valid() to get the first day of the next month or the last day of resulting month.

pub const fn add_years(self, years: i16) -> Result<Self, InvalidDayOfMonth>[src]

Compute a date by adding a number of years.

The resulting date may not be valid. You can call InvalidDayOfMonth::next_valid() or InvalidDayOfMonth::prev_valid() to get the first day of the next month or the last day of resulting month.

pub const fn sub_years(self, years: i16) -> Result<Self, InvalidDayOfMonth>[src]

Compute a date by subtracting a number of years.

The resulting date may not be valid. You can call InvalidDayOfMonth::next_valid() or InvalidDayOfMonth::prev_valid() to get the first day of the next month or the last day of resulting month.

Trait Implementations

impl Clone for Date[src]

impl Copy for Date[src]

impl Debug for Date[src]

impl Display for Date[src]

impl Eq for Date[src]

impl FromStr for Date[src]

type Err = DateParseError

The associated error which can be returned from parsing.

impl Hash for Date[src]

impl Ord for Date[src]

impl PartialEq<Date> for Date[src]

impl PartialOrd<Date> for Date[src]

impl StructuralEq for Date[src]

impl StructuralPartialEq for Date[src]

Auto Trait Implementations

impl RefUnwindSafe for Date

impl Send for Date

impl Sync for Date

impl Unpin for Date

impl UnwindSafe for Date

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.