Struct gregorian::Date

source ·
pub struct Date { /* private fields */ }
Expand description

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

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

Month and day numbers start at 1.

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

Day numbers start at 1.

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

Get the current date in the local time zone.

Get the current date of the UTC time zone.

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.

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.

Get the year.

Get the month.

Get the day of the month.

Get the year and month as YearMonth.

Get the day of the year.

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

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.

Get the total number of days since 1 January 0000.

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

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

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

Get a Date object for the next day.

Get a Date object for the previous day.

Compute a date by adding days.

Compute a date by subtracting days.

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.

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.

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.

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.

Compute the difference in days between two dates.

This does not include the end date. For example, difference between the same date will be 0.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.