pub struct DateRange {
pub start: Option<Date>,
pub end: Option<Date>,
}
Expand description
Represents a range based on whole or partial calendar dates, e.g. the duration of a hotel reservation or the Common Era. This can represent:
- A range between full dates, e.g. the duration of a hotel reservation
- A range between years, e.g. a historical era
- A range between year/month dates, e.g. the duration of a job on a resume
- A range beginning in a year, e.g. the Common Era
- A range ending on a specific date, e.g. the period of time before an event
While [google.type.Date][google.type.Date] allows zero years, DateRange does not. Year must always be non-zero.
End cannot be chronologically before start. For example, if start has year 2000, end cannot have year 1999.
When both set, start and end must have exactly the same precision. That is, they must have the same fields populated with non-zero values. For example, if start specifies only year and month, then end must also specify only year and month (but not day).
The date range is inclusive. That is, the dates specified by start and end are part of the date range. For example, the date January 1, 2000 falls within any date with start or end equal to January 1, 2000. When determining whether a date is inside a date range, the date should only be compared to start and end when those values are set.
When a date and date range are specified to different degrees of precision, the rules for evaluating whether that date is inside the date range are as follows:
-
When comparing the date to the start of the date range, unspecified months should be replaced with 1, and unspecified days should be replaced with 1. For example, the year 2000 is within the date range with start equal to January 1, 2000 and no end. And the date January 1, 2000 is within the date range with start equal to the year 2000 and no end.
-
When comparing the date to the end of the date range, unspecified months should be replaced with 12, and unspecified days should be replaced with the last valid day for the month/year. For example, the year 2000 is within the date range with start equal to January 1, 1999 and end equal to December 31, 2000. And the date December 31, 2001 is within the date range with start equal to the year 2000 and end equal to the year 2001.
The semantics of start and end are the same as those of [google.type.Date][google.type.Date], except that year must always be non-zero in DateRange.
Fields§
§start: Option<Date>
Date at which the date range begins. If unset, the date range has no beginning bound.
end: Option<Date>
Date at which the date range ends. If unset, the date range has no ending bound.
Trait Implementations§
source§impl Message for DateRange
impl Message for DateRange
source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moresource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.source§impl PartialEq for DateRange
impl PartialEq for DateRange
impl Copy for DateRange
impl StructuralPartialEq for DateRange
Auto Trait Implementations§
impl Freeze for DateRange
impl RefUnwindSafe for DateRange
impl Send for DateRange
impl Sync for DateRange
impl Unpin for DateRange
impl UnwindSafe for DateRange
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request