class
#include <bn_date.h>
date Manages a date represented by year, month, month day and week day.
Public static functions
- static auto valid(int year, int month, int month_day, int week_day) -> bool constexpr
- Indicates if the specified date is valid or not.
- static auto active() -> bool
- Indicates if the real time clock (RTC) is present or not.
- static auto current() -> optional<date>
- Returns the current date as reported by the real time clock (RTC) if it's present and the reported date is valid; bn::
nullopt otherwise.
Constructors, destructors, conversion operators
- date(int year, int month, int month_day, int week_day) constexpr
- Constructor.
Public functions
- auto year() const -> int constexpr
- Returns the year part of the date.
- void set_year(int year) constexpr
- Sets the year part of the date.
- auto month() const -> int constexpr
- Returns the month part of the date.
- void set_month(int month) constexpr
- Sets the month part of the date.
- auto month_day() const -> int constexpr
- Returns the month day part of the date.
- void set_month_day(int month_day) constexpr
- Sets the month day part of the date.
- auto week_day() const -> int constexpr
- Returns the week day part of the date.
- void set_week_day(int week_day) constexpr
- Sets the week day part of the date.
Friends
- auto operator==(date a, date b) -> bool defaulted constexpr
- Default equal operator.
- auto operator<(date a, date b) -> bool constexpr
- Less than operator.
- auto operator>(date a, date b) -> bool constexpr
- Greater than operator.
- auto operator<=(date a, date b) -> bool constexpr
- Less than or equal operator.
- auto operator>=(date a, date b) -> bool constexpr
- Greater than or equal operator.
Function documentation
static bool bn:: date:: valid(int year,
int month,
int month_day,
int week_day) constexpr
Indicates if the specified date is valid or not.
Parameters | |
---|---|
year | Year part of the date. |
month | Month part of the date, in the range [1..12]. |
month_day | Month day part of the date, in the range [1..31]. |
week_day | Week day part of the date, in the range [0..6]. |
Returns | true if the specified date is valid; false otherwise. |
bn:: date:: date(int year,
int month,
int month_day,
int week_day) constexpr
Constructor.
Parameters | |
---|---|
year | Year part of the date. |
month | Month part of the date, in the range [1..12]. |
month_day | Month day part of the date, in the range [1..31]. |
week_day | Week day part of the date, in the range [0..6]. |
void bn:: date:: set_year(int year) constexpr
Sets the year part of the date.
Parameters | |
---|---|
year | Year part of the date. |
void bn:: date:: set_month(int month) constexpr
Sets the month part of the date.
Parameters | |
---|---|
month | Month part of the date, in the range [1..12]. |
void bn:: date:: set_month_day(int month_day) constexpr
Sets the month day part of the date.
Parameters | |
---|---|
month_day | Month day part of the date, in the range [1..31]. |
void bn:: date:: set_week_day(int week_day) constexpr
Sets the week day part of the date.
Parameters | |
---|---|
week_day | Week day part of the date, in the range [0..6]. |
bool operator<=(date a, date b) constexpr
Less than or equal operator.
Parameters | |
---|---|
a | First date to compare. |
b | Second date to compare. |
Returns | true if the first date is earlier than or equal to the second one, otherwise false . |
bool operator>=(date a, date b) constexpr
Greater than or equal operator.
Parameters | |
---|---|
a | First date to compare. |
b | Second date to compare. |
Returns | true if the first date is later than or equal to the second one, otherwise false . |