date_time struct
A date-time.
Constructors, destructors, conversion operators
- date_time() defaulted noexcept
- Default constructor. Does not initialize the members.
-
date_time(toml::
date d, toml:: time t) constexpr noexcept - Constructs a local date-time.
-
date_time(toml::
date d) explicit constexpr noexcept - Constructs a local date-time.
-
date_time(toml::
time t) explicit constexpr noexcept - Constructs a local date-time.
-
date_time(toml::
date d, toml:: time t, toml:: time_offset off) constexpr noexcept - Constructs an offset date-time.
-
template <typename Duration>date_time(std::
chrono:: year_month_day d, std:: chrono:: hh_mm_ss<Duration> t) constexpr noexcept - Constructs a date_
time from year_month_day/hh_mm_ss values. -
date_time(std::
chrono:: year_month_day d) explicit constexpr noexcept - Constructs a date_
time from a year_month_day value. -
template <typename Duration>date_time(std::
chrono:: year_month_day d, std:: chrono:: hh_mm_ss<Duration> t, std:: chrono:: minutes off) constexpr noexcept - Constructs a date_
time from year_month_day/hh_mm_ss/minutes values. -
template <typename Duration>date_time(std::
chrono:: local_time<Duration> dt) constexpr noexcept - Constructs a date_
time from a local_time value. -
template <typename Duration>date_time(std::
chrono:: local_time<Duration> dt, std:: chrono:: minutes off) constexpr noexcept - Constructs a date_
time from a local_time value and a timezone offset.
Public functions
- auto is_local() const → bool constexpr noexcept
- Returns true if this date_
time does not contain timezone offset information. -
template <typename Duration = std::auto to_chrono() const → optional<std::
chrono:: nanoseconds> chrono:: local_time<Duration>> constexpr noexcept - Converts the date and time to a std::
chrono:: local_time. The offset is ignored.
Public variables
-
toml::
date date - The date component.
-
toml::
time time - The time component.
-
optional<toml::
time_offset> offset - The timezone offset component.
Friends
-
auto operator!=(const date_
time& lhs, const date_ time& rhs) → bool constexpr noexcept - Inequality operator.
-
auto operator<(const date_
time& lhs, const date_ time& rhs) → bool constexpr noexcept - Less-than operator.
-
auto operator<<(std::
ostream& lhs, const date_ time& rhs) → std:: ostream& - Prints a date_
time out to a stream in RFC 3339 format. -
auto operator<=(const date_
time& lhs, const date_ time& rhs) → bool constexpr noexcept - Less-than-or-equal-to operator.
-
auto operator==(const date_
time& lhs, const date_ time& rhs) → bool constexpr noexcept - Equality operator.
-
auto operator>(const date_
time& lhs, const date_ time& rhs) → bool constexpr noexcept - Greater-than operator.
-
auto operator>=(const date_
time& lhs, const date_ time& rhs) → bool constexpr noexcept - Greater-than-or-equal-to operator.
Function documentation
toml:: date_time:: date_time(toml:: date d,
toml:: time t) constexpr noexcept
Constructs a local date-time.
| Parameters | |
|---|---|
| d | The date component. |
| t | The time component. |
toml:: date_time:: date_time(toml:: date d) explicit constexpr noexcept
Constructs a local date-time.
| Parameters | |
|---|---|
| d | The date component. |
toml:: date_time:: date_time(toml:: time t) explicit constexpr noexcept
Constructs a local date-time.
| Parameters | |
|---|---|
| t | The time component. |
toml:: date_time:: date_time(toml:: date d,
toml:: time t,
toml:: time_offset off) constexpr noexcept
Constructs an offset date-time.
| Parameters | |
|---|---|
| d | The date component. |
| t | The time component. |
| off | The timezone offset. |
template <typename Duration>
toml:: date_time:: date_time(std:: chrono:: year_month_day d,
std:: chrono:: hh_mm_ss<Duration> t) constexpr noexcept
Constructs a date_
| Parameters | |
|---|---|
| d | The date component. |
| t | The time component. |
toml:: date_time:: date_time(std:: chrono:: year_month_day d) explicit constexpr noexcept
Constructs a date_
| Parameters | |
|---|---|
| d | The date component. |
template <typename Duration>
toml:: date_time:: date_time(std:: chrono:: year_month_day d,
std:: chrono:: hh_mm_ss<Duration> t,
std:: chrono:: minutes off) constexpr noexcept
Constructs a date_
| Parameters | |
|---|---|
| d | The date component. |
| t | The time component. |
| off | The timezone offset. |
template <typename Duration>
toml:: date_time:: date_time(std:: chrono:: local_time<Duration> dt) constexpr noexcept
Constructs a date_
| Parameters | |
|---|---|
| dt | The local_time component. |
template <typename Duration>
toml:: date_time:: date_time(std:: chrono:: local_time<Duration> dt,
std:: chrono:: minutes off) constexpr noexcept
Constructs a date_
| Parameters | |
|---|---|
| dt | The local_time component. |
| off | The timezone offset. |
template <typename Duration = std:: chrono:: nanoseconds>
optional<std:: chrono:: local_time<Duration>> toml:: date_time:: to_chrono() const constexpr noexcept
Converts the date and time to a std::
| Template parameters | |
|---|---|
| Duration | The duration type of the result. Finer parts are truncated. |
| Returns | The local time point, or an empty optional if it is out of range for Duration. |
std:: ostream& operator<<(std:: ostream& lhs,
const date_ time& rhs)
Prints a date_
std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 } } << "\n"; std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 }, { -2, -30 } } << "\n"; std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 }, {} } << "\n";
1987-03-16T10:20:34 1987-03-16T10:20:34-02:30 1987-03-16T10:20:34Z
Variable documentation
optional<toml:: time_offset> toml:: date_time:: offset
The timezone offset component.