11#include "azure/core/dll_import_export.hpp"
23 using period = std::ratio<1, 10000000>;
24 using duration = std::chrono::duration<rep, period>;
25 using time_point = std::chrono::time_point<Clock>;
41 static constexpr bool is_steady = std::chrono::system_clock::is_steady;
42 static time_point now();
54class DateTime final :
public _detail::Clock::time_point {
57 AZ_CORE_DLLEXPORT
static DateTime const SystemClockEpoch;
68 int8_t localDiffHours,
69 int8_t localDiffMinutes,
70 bool roundFracSecUp =
false);
72 void ThrowIfUnsupportedYear()
const;
74 void GetDateTimeParts(
82 int8_t* dayOfWeek)
const;
84 std::string ToStringRfc1123()
const;
112 :
DateTime(year, month, day, hour, minute, second, 0, -1, 0, 0)
127 DateTime(std::chrono::system_clock::time_point
const& systemTime)
129 SystemClockEpoch + std::chrono::duration_cast<duration>(systemTime.time_since_epoch()))
139 explicit operator std::chrono::system_clock::time_point()
const;
206inline _detail::Clock::time_point _detail::Clock::now()
208 return DateTime(std::chrono::system_clock::now());
283namespace Core {
namespace _internal {
288 class PosixTimeConverter final {
296 static DateTime PosixTimeToDateTime(int64_t posixTime)
298 return {DateTime(1970) + std::chrono::seconds(posixTime)};
307 static int64_t DateTimeToPosixTime(DateTime
const& dateTime)
310 return std::chrono::duration_cast<std::chrono::seconds>(dateTime - DateTime(1970)).count();
318 PosixTimeConverter() =
delete;
325 ~PosixTimeConverter() =
delete;
Manages date and time in standardized string formats.
Definition datetime.hpp:54
constexpr DateTime(time_point const &timePoint)
Constructs an instance of DateTime from a time_point.
Definition datetime.hpp:120
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.
Definition datetime.hpp:105
operator std::chrono::system_clock::time_point() const
Convert an instance of Azure::DateTime to std::chrono::system_clock::time_point.
Definition datetime.cpp:424
DateTime(std::chrono::system_clock::time_point const &systemTime)
Construct an instance of DateTime from std::chrono::system_clock::time_point.
Definition datetime.hpp:127
constexpr DateTime()
Constructs a default instance of DateTime (00:00:00.0000000 on January 1st, 0001).
Definition datetime.hpp:91
TimeFractionFormat
Defines the format applied to the fraction part of any Azure::DateTime.
Definition datetime.hpp:146
@ Truncate
Drop all the fractional time digits.
@ DropTrailingZeros
Include only meaningful fractional time digits, up to and excluding trailing zeroes.
DateFormat
Defines the supported date and time string formats.
Definition datetime.hpp:163
static DateTime Parse(std::string const &dateTime, DateFormat format)
Create Azure::DateTime from a string representing time in UTC in the specified format.
Definition datetime.cpp:451
std::string ToString(DateFormat format=DateFormat::Rfc3339) const
Get a string representation of the Azure::DateTime.
Definition datetime.cpp:850
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57
bool operator<=(DateTime const &dt, std::chrono::system_clock::time_point const &tp)
Compare a DateTime object with a std::chrono::system_clock::time_point object.
Definition datetime.hpp:224
bool operator>=(DateTime const &dt, std::chrono::system_clock::time_point const &tp)
Compare a DateTime object with a std::chrono::system_clock::time_point object.
Definition datetime.hpp:242
bool operator>(DateTime const &dt, std::chrono::system_clock::time_point const &tp)
Compare a DateTime object with a std::chrono::system_clock::time_point object.
Definition datetime.hpp:236
bool operator!=(DateTime const &dt, std::chrono::system_clock::time_point const &tp)
Compare a DateTime object with a std::chrono::system_clock::time_point object.
Definition datetime.hpp:230
bool operator<(DateTime const &dt, std::chrono::system_clock::time_point const &tp)
Compare a DateTime object with a std::chrono::system_clock::time_point object.
Definition datetime.hpp:218
bool operator==(DateTime const &dt, std::chrono::system_clock::time_point const &tp)
Compare a DateTime object with a std::chrono::system_clock::time_point object.
Definition datetime.hpp:212