Type to represent google.type.Date
in proto structs.
This type is organized in the same way as its protobuf counterpart and allows for the same range of values described here https://github.com/googleapis/googleapis/blob/master/google/type/date.proto :
- a full date, with non-zero year, month, and day values
- a year and month value, with a zero day, such as a credit card expiration date
- a year on its own, with zero month and day values
- a month and day value, with a zero year, such as an anniversary
The year part of the date must be in the [1, 9999]
range. The month should be in the [1, 12]
range. The day should be in the [1, 31]
range. Altogether, year, month and day must represent a valid date.
Definition at line 31 of file date.hpp.
|
constexpr | Date ()=default |
| Creates empty date with all components unset.
|
|
constexpr | Date (const std::optional< std::chrono::year > &year, const std::optional< std::chrono::month > &month, const std::optional< std::chrono::day > &day) |
| Creates date.
|
|
constexpr | Date (const std::chrono::year_month_day &ymd) |
| Creates full date.
|
|
constexpr | Date (const std::chrono::year_month &ym) |
| Creates date without a day.
|
|
constexpr | Date (const std::chrono::month_day &md) |
| Creates date without a year.
|
|
constexpr | Date (const std::chrono::year &year) |
| Creates date holding only year.
|
|
constexpr | Date (const utils::datetime::Date &date) |
| Creates full date.
|
|
constexpr | Date (const std::chrono::sys_days &sys_days) |
| Creates full date from std::chrono::sys_days .
|
|
| Date (utils::impl::InternalTag, std::int32_t year, std::int32_t month, std::int32_t day) |
|
constexpr const std::optional< std::chrono::year > & | Year () const noexcept |
| Returns year.
|
|
constexpr const std::optional< std::chrono::month > & | Month () const noexcept |
| Returns month.
|
|
constexpr const std::optional< std::chrono::day > & | Day () const noexcept |
| Returns day.
|
|
constexpr std::int32_t | YearNum () const noexcept |
| Returns year as integer.
|
|
constexpr std::int32_t | MonthNum () const noexcept |
| Returns month as integer.
|
|
constexpr std::int32_t | DayNum () const noexcept |
| Returns day as integer.
|
|
constexpr std::chrono::year_month_day | ToChronoDate () const |
| Converts date to std::chrono::year_month_day .
|
|
constexpr std::chrono::year_month | ToChronoYearMonth () const |
| Converts date to std::chrono::year_month .
|
|
constexpr std::chrono::month_day | ToChronoMonthDay () const |
| Converts date to std::chrono::month_day .
|
|
constexpr std::chrono::year | ToChronoYear () const |
| Converts date to std::chrono::year .
|
|
constexpr std::chrono::sys_days | ToChronoSysDays () const |
| Converts date to std::chrono::sys_days .
|
|
utils::datetime::Date | ToUserverDate () const |
| Converts date to userver::utils::datetime::Date .
|
|
constexpr bool | IsEmpty () const noexcept |
| Returns true if date is empty (i.e. all components are not set).
|
|
constexpr bool | HasYearMonthDay () const noexcept |
| Returns true if date has all components.
|
|
constexpr bool | HasYearMonth () const noexcept |
| Returns true if date is has year and month.
|
|
constexpr bool | HasMonthDay () const noexcept |
| Returns true if date is has month and day.
|
|
constexpr bool | HasYear () const noexcept |
| Returns true if date is has year.
|
|
constexpr | operator std::chrono::year_month_day () const |
| Explicit conversion to std::chrono::year_month_day .
|
|
constexpr | operator std::chrono::year_month () const |
| Explicit conversion to std::chrono::year_month .
|
|
constexpr | operator std::chrono::month_day () const |
| Explicit conversion to std::chrono::month_day .
|
|
constexpr | operator std::chrono::year () const |
| Explicit conversion to std::chrono::year .
|
|
constexpr | operator std::chrono::sys_days () const |
| Explicit conversion to std::chrono::sys_days .
|
|
constexpr | operator utils::datetime::Date () const |
| Explicit conversion to userver::utils::datetime::Date .
|
|
constexpr auto | operator<=> (const Date &) const =default |
| Default three-way comparison operator.
|
|