Represents a point in time, expressed as a date and time of day.
More...
#include <chrono.hpp>
|
bool | valid () const noexcept |
| Returns whether this object contains a valid date and time.
|
|
bool | equals (const datetime &other) const noexcept |
| Returns whether this object is equal to other .
|
|
void | value (const datetime &x) noexcept |
| Overrides the current date and time with the values from x .
|
|
template<class Duration = std::chrono::system_clock::duration> |
auto | to_local_time () const noexcept |
| Converts this object to a time_point object with given Duration type.
|
|
template<class Resolution = std::chrono::nanoseconds, class Policy = unit_t> |
std::string | to_string () const |
| Formats this object in ISO 8601 format.
|
|
void | force_utc () |
| Converts this object to UTC.
|
|
template<class Resolution = std::chrono::nanoseconds, class Policy = unit_t, class OutputIterator > |
OutputIterator | print_to (OutputIterator out) const |
| Formats this object in ISO 8601 format and writes the result to out .
|
|
|
static expected< datetime > | from_string (std::string_view str) |
| Convenience function for converting a string to a datetime object.
|
|
template<class Duration > |
static datetime | from_local_time (sys_time< Duration > src) |
| Converts a local time to a datetime object.
|
|
|
int | year = 0 |
| The year.
|
|
int | month = 0 |
| The month of the year, starting with 1 for January.
|
|
int | day = 0 |
| The day of the month, starting with 1.
|
|
int | hour = 0 |
| The hour of the day, starting with 0.
|
|
int | minute = 0 |
| The minute of the hour, starting with 0.
|
|
int | second = 0 |
| The second of the minute, starting with 0.
|
|
int | nanosecond = 0 |
| The nanosecond of the second, starting with 0.
|
|
std::optional< int > | utc_offset |
| The offset from UTC in seconds.
|
|
|
(Note that these are not member symbols.)
|
bool | operator== (const datetime &x, const datetime &y) noexcept |
|
bool | operator!= (const datetime &x, const datetime &y) noexcept |
|
CAF_CORE_EXPORT error | parse (std::string_view str, datetime &dest) |
| Parses a date and time string in ISO 8601 format.
|
|
CAF_CORE_EXPORT void | parse (string_parser_state &ps, datetime &dest) |
| Parses a date and time string in ISO 8601 format.
|
|
CAF_CORE_EXPORT std::string | to_string (const datetime &x) |
|
Represents a point in time, expressed as a date and time of day.
Also provides formatting and parsing functionality for ISO 8601.
◆ force_utc()
void caf::chrono::datetime::force_utc |
( |
| ) |
|
Converts this object to UTC.
- Postcondition
utc_offset == 0
◆ print_to()
template<class Resolution = std::chrono::nanoseconds, class Policy = unit_t, class OutputIterator >
OutputIterator caf::chrono::datetime::print_to |
( |
OutputIterator | out | ) |
const |
Formats this object in ISO 8601 format and writes the result to out
.
- Template Parameters
-
Resolution | The resolution for the fractional part of the seconds. |
Policy | Either fixed to force a fixed number of fractional digits or unit_t (default) to use a variable number. |
◆ to_local_time()
template<class Duration = std::chrono::system_clock::duration>
auto caf::chrono::datetime::to_local_time |
( |
| ) |
const |
|
noexcept |
Converts this object to a time_point object with given Duration type.
- Precondition
valid()
returns true
.
◆ to_string()
template<class Resolution = std::chrono::nanoseconds, class Policy = unit_t>
std::string caf::chrono::datetime::to_string |
( |
| ) |
const |
Formats this object in ISO 8601 format.
- Template Parameters
-
Resolution | The resolution for the fractional part of the seconds. |
Policy | Either fixed to force a fixed number of fractional digits or unit_t (default) to use a variable number. |
◆ valid()
bool caf::chrono::datetime::valid |
( |
| ) |
const |
|
noexcept |
Returns whether this object contains a valid date and time.
A default constructed object is invalid.
◆ parse() [1/2]
CAF_CORE_EXPORT error parse |
( |
std::string_view | str, |
|
|
datetime & | dest ) |
|
related |
Parses a date and time string in ISO 8601 format.
- Parameters
-
str | The string to parse. |
dest | The output parameter for the parsed date and time. |
- Returns
- An error code if parsing failed.
◆ parse() [2/2]
Parses a date and time string in ISO 8601 format.
- Parameters
-
ps | The parser state to use. |
dest | The output parameter for the parsed date and time. |
The documentation for this class was generated from the following files:
- libcaf_core/caf/chrono.hpp
- libcaf_core/caf/chrono.cpp