AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
DateTime.h
1
6#pragma once
7
8#include <aws/core/Core_EXPORTS.h>
9#include <aws/core/utils/memory/stl/AWSString.h>
10#include <aws/core/utils/logging/LogMacros.h>
11#include <chrono>
12
13namespace Aws
14{
15 namespace Utils
16 {
17 enum class DateFormat
18 {
19 RFC822, //for http headers
20 ISO_8601, //for query and xml payloads
21 ISO_8601_BASIC, // for retry headers and signers
23 };
24
25 enum class Month
26 {
27 January = 0,
29 March,
30 April,
31 May,
32 June,
33 July,
34 August,
36 October,
39 };
40
41 enum class DayOfWeek
42 {
43 Sunday = 0,
44 Monday,
45 Tuesday,
48 Friday,
50 };
51
55 class AWS_CORE_API DateTime
56 {
57 public:
62
66 DateTime(const std::chrono::system_clock::time_point& timepointToAssign);
67
71 DateTime(int64_t millisSinceEpoch);
72
78 DateTime(double secondsSinceEpoch);
79
83 DateTime(const Aws::String& timestamp, DateFormat format);
84
88 DateTime(const char* timestamp, DateFormat format);
89
90 bool operator == (const DateTime& other) const;
91 bool operator < (const DateTime& other) const;
92 bool operator > (const DateTime& other) const;
93 bool operator != (const DateTime& other) const;
94 bool operator <= (const DateTime& other) const;
95 bool operator >= (const DateTime& other) const;
96
97 DateTime operator+(const std::chrono::milliseconds& a) const;
98 DateTime operator-(const std::chrono::milliseconds& a) const;
99
105 DateTime& operator=(double secondsSinceEpoch);
106
110 DateTime& operator=(int64_t millisSinceEpoch);
111
115 DateTime& operator=(const std::chrono::system_clock::time_point& timepointToAssign);
116
120 DateTime& operator=(const Aws::String& timestamp);
121
125 inline bool WasParseSuccessful() const { return m_valid; }
126
131
135 Aws::String ToLocalTimeString(const char* formatStr) const;
136
141
145 Aws::String ToGmtString(const char* formatStr) const;
146
151
158
162 int64_t Seconds() const;
163
167 int64_t Millis() const;
168
172 std::chrono::system_clock::time_point UnderlyingTimestamp() const;
173
177 int GetYear(bool localTime = false) const;
178
182 Month GetMonth(bool localTime = false) const;
183
187 int GetDay(bool localTime = false) const;
188
192 DayOfWeek GetDayOfWeek(bool localTime = false) const;
193
197 int GetHour(bool localTime = false) const;
198
202 int GetMinute(bool localTime = false) const;
203
207 int GetSecond(bool localTime = false) const;
208
212 bool IsDST(bool localTime = false) const;
213
217 static DateTime Now();
218
222 static int64_t CurrentTimeMillis();
223
227 static Aws::String CalculateLocalTimestampAsString(const char* formatStr);
228
232 static Aws::String CalculateGmtTimestampAsString(const char* formatStr);
233
238
243
249
253 static std::chrono::milliseconds Diff(const DateTime& a, const DateTime& b);
254
255 std::chrono::milliseconds operator - (const DateTime& other) const;
256 private:
257 std::chrono::system_clock::time_point m_time;
258 bool m_valid;
259
260 void ConvertTimestampStringToTimePoint(const char* timestamp, DateFormat format);
261 tm GetTimeStruct(bool localTime) const;
262 tm ConvertTimestampToLocalTimeStruct() const;
263 tm ConvertTimestampToGmtStruct() const;
264 };
265
266 } // namespace Utils
267} // namespace Aws
DateTime(const char *timestamp, DateFormat format)
DateTime & operator=(int64_t millisSinceEpoch)
DateTime operator-(const std::chrono::milliseconds &a) const
int GetYear(bool localTime=false) const
static Aws::String CalculateLocalTimestampAsString(const char *formatStr)
DateTime(int64_t millisSinceEpoch)
DateTime operator+(const std::chrono::milliseconds &a) const
DateTime(const std::chrono::system_clock::time_point &timepointToAssign)
DateTime(double secondsSinceEpoch)
static std::chrono::milliseconds Diff(const DateTime &a, const DateTime &b)
Aws::String ToGmtString(const char *formatStr) const
static Aws::String CalculateGmtTimeWithMsPrecision()
DayOfWeek GetDayOfWeek(bool localTime=false) const
Aws::String ToGmtString(DateFormat format) const
int GetMinute(bool localTime=false) const
Aws::String ToLocalTimeString(DateFormat format) const
static int CalculateCurrentHour()
DateTime & operator=(const std::chrono::system_clock::time_point &timepointToAssign)
std::chrono::system_clock::time_point UnderlyingTimestamp() const
int64_t Seconds() const
static DateTime Now()
Month GetMonth(bool localTime=false) const
int64_t Millis() const
static int64_t CurrentTimeMillis()
bool IsDST(bool localTime=false) const
static Aws::String CalculateGmtTimestampAsString(const char *formatStr)
DateTime(const Aws::String &timestamp, DateFormat format)
double SecondsWithMSPrecision() const
int GetHour(bool localTime=false) const
DateTime & operator=(double secondsSinceEpoch)
Aws::String ToGmtStringWithMs() const
bool WasParseSuccessful() const
Definition DateTime.h:125
int GetDay(bool localTime=false) const
int GetSecond(bool localTime=false) const
static double ComputeCurrentTimestampInAmazonFormat()
DateTime & operator=(const Aws::String &timestamp)
Aws::String ToLocalTimeString(const char *formatStr) const
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition AWSString.h:97