#include <DateTime.h>
Public Types | |
enum class | PrintAccuracy { MINUTES = 1 , SECONDS = 2 , MILLISECONDS = 3 } |
enum class | Format { DATE_FORMAT , DATE_PARTS_ORDER , FULL_TIME_FORMAT , SHORT_TIME_FORMAT , MONTH_NAME , WEEKDAY_NAME } |
using | clock = std::chrono::system_clock |
using | time_point = std::chrono::system_clock::time_point |
using | duration = std::chrono::system_clock::duration |
Public Member Functions | |
DateTime (short y, short m, short d, short h=0, short mm=0, short s=0, short ms=0) | |
DateTime (const char *dateStr=nullptr) | |
DateTime (const DateTime &dt)=default | |
DateTime (DateTime &&dt)=default | |
DateTime (const time_point &dt) | |
DateTime (const duration &dt) | |
const time_point & | timePoint () const |
DateTime & | operator= (const DateTime &date)=default |
void | formatDate (std::ostream &str, int printFlags=0) const |
void | formatTime (std::ostream &str, int printFlags=0, PrintAccuracy printAccuracy=PrintAccuracy::SECONDS) const |
duration | sinceEpoch () const |
int16_t | daysInMonth () const |
int16_t | dayOfWeek () const |
String | dayOfWeekName () const |
String | monthName () const |
DateTime | date () const |
String | dateString (int printFlags=0) const |
String | timeString (int printFlags=0, PrintAccuracy printAccuracy=PrintAccuracy::SECONDS) const |
String | isoDateTimeString (PrintAccuracy printAccuracy=PrintAccuracy::SECONDS, bool gmt=false) const |
operator String () const | |
operator time_t () 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 |
bool | zero () const |
Static Public Member Functions | |
static String | format (Format dtFormat, size_t arg=0) |
static char | dateSeparator () |
static char | timeSeparator () |
static bool | time24Mode () |
static void | time24Mode (bool t24mode) |
static DateTime | Now () |
static DateTime | convertCTime (const time_t tt) |
static std::chrono::minutes | timeZoneOffset () |
static String | timeZoneName () |
static bool | isDaylightSavingsTime () |
Static Public Attributes | |
static constexpr int | PF_RFC_DATE = 1 |
static constexpr int | PF_TIMEZONE = 2 |
static constexpr int | PF_12HOURS = 4 |
static constexpr int | PF_GMT = 16 |
Friends | |
class | DateTimeFormat |
Date and Time value.
Represents the date and time value. This value is stored as a floating point number. Allows to synchronize the Now() time with the external date/time, without affecting the local host system time.
using sptk::DateTime::clock = std::chrono::system_clock |
Clock used by DateTime
using sptk::DateTime::duration = std::chrono::system_clock::duration |
DateTime::duration type definition
using sptk::DateTime::time_point = std::chrono::system_clock::time_point |
DateTime::time_point type definition
|
strong |
Time print accuracy
sptk::DateTime::DateTime | ( | short | y, |
short | m, | ||
short | d, | ||
short | h = 0 , |
||
short | mm = 0 , |
||
short | s = 0 , |
||
short | ms = 0 |
||
) |
Constructor
y | Year |
m | Month |
d | Day |
h | Hour |
mm | Minute |
s | Second |
ms | Millisecond |
|
explicit |
Constructor
dateStr | Date string |
|
default |
Copy constructor
|
default |
Move constructor
|
explicit |
Constructor
dt | Time point |
|
explicit |
Constructor
dt | Duration since epoch |
|
static |
Converts C time into DateTime
tt | C time to convert |
DateTime sptk::DateTime::date | ( | ) | const |
Reports the date part only
Referenced by sptk::CPopupCalendar::date().
|
static |
System's date separator
String sptk::DateTime::dateString | ( | int | printFlags = 0 | ) | const |
Returns date as a string
printFlags | Print flags, recognised { PF_GMT, PF_RFC_DATE } |
int16_t sptk::DateTime::dayOfWeek | ( | ) | const |
Reports the day of the week in this date (1..7)
String sptk::DateTime::dayOfWeekName | ( | ) | const |
Reports the day of the week name in this date ('Sunday'..'Saturday')
int16_t sptk::DateTime::daysInMonth | ( | ) | const |
Reports the number of days in the month in this date (1..31)
void sptk::DateTime::decodeDate | ( | short * | year, |
short * | month, | ||
short * | day, | ||
short * | wday, | ||
short * | yday, | ||
bool | gmt = false |
||
) | const |
Decodes date into y,m,d
void sptk::DateTime::decodeTime | ( | short * | h, |
short * | m, | ||
short * | s, | ||
short * | ms, | ||
bool | gmt = false |
||
) | const |
Decodes time into h,m,s,ms
|
static |
System's format info
dtFormat | Format type |
arg | Optional format argument, for MONTH_NAME and WEEKDAY_NAME |
void sptk::DateTime::formatDate | ( | std::ostream & | str, |
int | printFlags = 0 |
||
) | const |
Print the date into stream
str | Output stream |
printFlags | Print flags, recognised { PF_GMT, PF_RFC_DATE } |
void sptk::DateTime::formatTime | ( | std::ostream & | str, |
int | printFlags = 0 , |
||
PrintAccuracy | printAccuracy = PrintAccuracy::SECONDS |
||
) | const |
Print date into string
str | Output stream |
printFlags | Print flags, recognised { PF_GMT, PF_TIMEZONE, PF_12HOURS } |
printAccuracy | Print accuracy, |
|
static |
Returns true if daylight savings time
String sptk::DateTime::isoDateTimeString | ( | PrintAccuracy | printAccuracy = PrintAccuracy::SECONDS , |
bool | gmt = false |
||
) | const |
Returns time as a ISO date and time string
printAccuracy | Print accuracy, |
gmt | If true print GMT time |
String sptk::DateTime::monthName | ( | ) | const |
Reports the month name in this date ('Sunday'..'Saturday')
|
static |
Reports the current date and time.
|
inlineexplicit |
Returns date and time as a string
|
inlineexplicit |
Returns time_t presentation
|
inline |
Duration since epoch
|
static |
Returns system's time mode.
|
static |
Sets system's time mode
|
inline |
Returns time_point presentation of the date and time
|
static |
System's time separator
String sptk::DateTime::timeString | ( | int | printFlags = 0 , |
PrintAccuracy | printAccuracy = PrintAccuracy::SECONDS |
||
) | const |
Returns time as a string
printFlags | Print flags, recognised { PF_GMT, PF_TIMEZONE, PF_12HOURS } |
printAccuracy | Print accuracy, |
|
static |
Returns timezone name
|
static |
Returns timezone offset in minutes
|
inline |
Return true if date and time are at epoch
|
staticconstexpr |
Date and time print flags