|
Manages date and time in standardized string formats. More...
#include <datetime.hpp>
Public Types | |
enum | TimeFractionFormat { TimeFractionFormat::DropTrailingZeros, TimeFractionFormat::AllDigits, TimeFractionFormat::Truncate } |
Defines the format applied to the fraction part of any Azure::DateTime. More... | |
enum | DateFormat { DateFormat::Rfc1123, DateFormat::Rfc3339 } |
Defines the supported date and time string formats. More... | |
Public Member Functions | |
constexpr | DateTime () |
Constructs a default instance of DateTime (00:00:00.0000000 on January 1st, 0001 ). More... | |
DateTime (int16_t year, int8_t month=1, int8_t day=1, int8_t hour=0, int8_t minute=0, int8_t second=0) | |
Constructs an instance of DateTime . More... | |
constexpr | DateTime (time_point const &timePoint) |
Constructs an instance of DateTime from a time_point . More... | |
DateTime (std::chrono::system_clock::time_point const &systemTime) | |
Construct an instance of DateTime from std::chrono::system_clock::time_point . More... | |
operator std::chrono::system_clock::time_point () const | |
Convert an instance of Azure::DateTime to std::chrono::system_clock::time_point . More... | |
std::string | ToString (DateFormat format=DateFormat::Rfc3339) const |
Get a string representation of the Azure::DateTime. More... | |
std::string | ToString (DateFormat format, TimeFractionFormat fractionFormat) const |
Get a string representation of the Azure::DateTime. More... | |
Static Public Member Functions | |
static DateTime | Parse (std::string const &dateTime, DateFormat format) |
Create Azure::DateTime from a string representing time in UTC in the specified format. More... | |
Supports date range from year 0001 to end of year 9999 with 100ns (7 decimal places for fractional second) precision.
std::chrono::system_clock::time_point
can't be used, because there is no guarantees for the date range and precision.
|
strong |
|
strong |
|
inlineconstexpr |
|
inlineexplicit |
year | Year. |
month | Month. |
day | Day. |
hour | Hour. |
minute | Minute. |
second | Seconds. |
std::invalid_argument | If any parameter is invalid. |
|
inlineconstexpr |
|
inline |
systemTime | A value of std::chrono::system_clock::time_point . |
|
explicit |
std::invalid_argument | if Azure::DateTime is outside of the range that can be represented. |
|
static |
dateTime | A string with the date and time. |
format | A format to which dateTime string adheres to. |
dateTime
string.std::invalid_argument | If format is not recognized, or if parsing error. |
std::string DateTime::ToString | ( | DateFormat | format, |
TimeFractionFormat | fractionFormat | ||
) | const |
format | The representation format to use. |
fractionFormat | The format for the fraction part of the DateTime. Only supported by RFC3339. |
std::invalid_argument | If year exceeds 9999, or if format is not recognized. |
std::string DateTime::ToString | ( | DateFormat | format = DateFormat::Rfc3339 | ) | const |
format | The representation format to use, defaulted to use RFC 3339. |
std::invalid_argument | If year exceeds 9999, or if format is not recognized. |