pub struct Date {
pub year: Option<i16>,
pub month: Option<i8>,
pub day: Option<i8>,
}Expand description
Represents a whole or partial calendar date, such as a birthday.
The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following:
- A full date, with non-zero year, month, and day values.
- A month and day, with a zero year (for example, an anniversary).
- A year on its own, with a zero month and a zero day.
- A year and month, with a zero day (for example, a credit card expiration date).
Related types:
- google.type.TimeOfDay
- google.type.DateTime
- google.protobuf.Timestamp
Fields§
§year: Option<i16>Year of the date.
Must be from 1 to 9_999, or 0 to specify a date without a year.
month: Option<i8>Month of a year.
Must be from 1 to 12, or 0 to specify a year without a month and day.
day: Option<i8>Day of a month.
Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by
itself or a year and month where the day isn’t significant.
Implementations§
Source§impl Date
impl Date
Source§impl Date
impl Date
Sourcepub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Returns whether this is a complete date (has year, month, and day).
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns whether this date is completely empty (no components specified).
Sourcepub fn try_to_jiff_date(&self) -> Result<Option<JiffDate>, Error>
pub fn try_to_jiff_date(&self) -> Result<Option<JiffDate>, Error>
Attempts to convert this Date to a jiff::civil::Date.
Returns a Date if this Date has complete year, month, and day information and represents a
valid calendar date. Returns None for incomplete dates.
§Errors
Returns an error if the date components form an invalid date (e.g., February 30th).
Sourcepub fn to_jiff_date(&self) -> Option<JiffDate>
pub fn to_jiff_date(&self) -> Option<JiffDate>
Gets a jiff::civil::Date if this is a complete and valid date.
This is a convenience method that returns None if the conversion fails rather than
returning an error.
Sourcepub fn from_jiff_date(jiff_date: &JiffDate) -> Self
pub fn from_jiff_date(jiff_date: &JiffDate) -> Self
Creates a Date from a jiff::civil::Date.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Date
impl<'de> Deserialize<'de> for Date
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl TryFrom<&Date> for Option<Date>
impl TryFrom<&Date> for Option<Date>
Source§fn try_from(date: &Date) -> Result<Self, Self::Error>
fn try_from(date: &Date) -> Result<Self, Self::Error>
Converts a Google Maps Places (new) Date to an Option<jiff::civil::Date>.
Requires the Date to have complete year, month, and day components that form a valid
calendar date or this will return None.
§Errors
Returns an error if the components form an invalid date.
impl Copy for Date
impl Eq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
impl Freeze for Date
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.