32#include <sptk5/String.h>
33#include <sptk5/sptk.h>
61 static std::chrono::minutes
offset();
87 friend class DateTimeFormat;
93 using clock = std::chrono::system_clock;
98 using time_point = std::chrono::system_clock::time_point;
103 using duration = std::chrono::system_clock::duration;
118 static constexpr int PF_RFC_DATE = 1;
119 static constexpr int PF_TIMEZONE = 2;
120 static constexpr int PF_12HOURS = 4;
121 static constexpr int PF_GMT = 16;
170 DateTime(
short y,
short m,
short d,
short h = 0,
short mm = 0,
short s = 0,
short ms = 0);
218 void formatDate(std::ostream& str,
int printFlags = 0)
const;
233 return m_dateTime.time_since_epoch();
315 return dateString() +
" " + timeString();
321 explicit operator time_t()
const
323 return clock::to_time_t(m_dateTime);
329 void decodeDate(
short* year,
short* month,
short* day,
short* wday,
short* yday,
bool gmt =
false)
const;
334 void decodeTime(
short* h,
short* m,
short* s,
short* ms,
bool gmt =
false)
const;
341 return m_dateTime.time_since_epoch().count() == 0;
345 time_point m_dateTime;
347 static String _dateFormat;
348 static String _fullTimeFormat;
349 static String _shortTimeFormat;
350 static String _datePartsOrder;
351 static char _dateSeparator;
352 static char _timeSeparator;
356 static bool _time24Mode;
357 static String _timeZoneName;
358 static std::chrono::minutes _timeZoneOffset;
359 static int _isDaylightSavingsTime;
Definition: DateTime.h:86
static DateTime convertCTime(const time_t tt)
static char timeSeparator()
static String format(Format dtFormat, size_t arg=0)
static bool isDaylightSavingsTime()
std::chrono::system_clock::time_point time_point
Definition: DateTime.h:98
int16_t dayOfWeek() const
void decodeDate(short *year, short *month, short *day, short *wday, short *yday, bool gmt=false) const
void decodeTime(short *h, short *m, short *s, short *ms, bool gmt=false) const
int16_t daysInMonth() const
DateTime(DateTime &&dt)=default
static std::chrono::minutes timeZoneOffset()
String isoDateTimeString(PrintAccuracy printAccuracy=PrintAccuracy::SECONDS, bool gmt=false) const
const time_point & timePoint() const
Definition: DateTime.h:203
DateTime & operator=(const DateTime &date)=default
String dayOfWeekName() const
DateTime(const time_point &dt)
static char dateSeparator()
std::chrono::system_clock::duration duration
Definition: DateTime.h:103
duration sinceEpoch() const
Definition: DateTime.h:231
DateTime(const DateTime &dt)=default
PrintAccuracy
Definition: DateTime.h:109
bool zero() const
Definition: DateTime.h:339
DateTime(const duration &dt)
std::chrono::system_clock clock
Definition: DateTime.h:93
DateTime(short y, short m, short d, short h=0, short mm=0, short s=0, short ms=0)
String dateString(int printFlags=0) const
DateTime(const char *dateStr=nullptr)
String timeString(int printFlags=0, PrintAccuracy printAccuracy=PrintAccuracy::SECONDS) const
void formatDate(std::ostream &str, int printFlags=0) const
static void time24Mode(bool t24mode)
void formatTime(std::ostream &str, int printFlags=0, PrintAccuracy printAccuracy=PrintAccuracy::SECONDS) const
static String timeZoneName()
Definition: DateTime.h:50
static void set(const sptk::String &timeZoneName)
static int isDaylightSavingsTime()
static std::chrono::minutes offset()
SP_EXPORT sptk::DateTime::duration operator-(const sptk::DateTime &dt1, const sptk::DateTime &dt2)
SP_EXPORT bool operator>(const sptk::DateTime &dt1, const sptk::DateTime &dt2)
SP_EXPORT sptk::DateTime operator+(const sptk::DateTime &dt1, const sptk::DateTime::duration &duration)
SP_EXPORT bool operator<=(const sptk::DateTime &dt1, const sptk::DateTime &dt2)
SP_EXPORT bool operator<(const sptk::DateTime &dt1, const sptk::DateTime &dt2)
SP_EXPORT bool operator==(const sptk::DateTime &dt1, const sptk::DateTime &dt2)
SP_EXPORT bool operator!=(const sptk::DateTime &dt1, const sptk::DateTime &dt2)
SP_EXPORT double duration2seconds(const sptk::DateTime::duration &duration)
SP_EXPORT bool operator>=(const sptk::DateTime &dt1, const sptk::DateTime &dt2)