8 #ifndef XCLOX_DATE_TIME_HPP
9 #define XCLOX_DATE_TIME_HPP
48 using Duration = std::chrono::nanoseconds;
97 const auto& subDay = duration %
Days(1);
98 const auto& floatingDay =
Days(duration.count() < 0 && subDay.count() != 0 ? 1 : 0);
99 m_date =
Date(std::chrono::duration_cast<Days>(duration - floatingDay));
100 m_time =
Time(subDay + floatingDay);
104 explicit DateTime(
const std::chrono::system_clock::time_point& timePoint)
105 :
DateTime(timePoint.time_since_epoch())
149 return (this->m_date < other.m_date) || (this->m_date == other.m_date && this->m_time < other.m_time);
155 return (this->m_date <= other.m_date) || (this->m_date == other.m_date && this->m_time <= other.m_time);
161 return (this->m_date > other.m_date) || (this->m_date == other.m_date && this->m_time > other.m_time);
167 return (this->m_date >= other.m_date) || (this->m_date == other.m_date && this->m_time >= other.m_time);
173 return this->m_date == other.m_date && this->m_time == other.m_time;
179 return this->m_date != other.m_date || this->m_time != other.m_time;
264 return m_time.
hour();
276 return m_date.
month();
282 return m_date.
year();
500 if (duration.count() < 0)
504 return DateTime(m_date.
addDays(std::chrono::duration_cast<Days>(totalDuration).count()),
Time(totalDuration %
Days(1)));
510 if (duration.count() < 0)
582 std::tm cTime = { 0 };
583 cTime.tm_year = y - 1970;
586 cTime.tm_hour =
hour();
655 std::string
toString(
const std::string& format =
"yyyy-MM-dd hh:mm:ss")
const
657 if (!
isValid() || format.empty())
658 return std::string();
659 std::stringstream output;
660 for (
size_t pos = 0; pos < format.size(); ++pos) {
661 const auto count = internal::countIdenticalCharsFrom(pos, format);
662 output << (internal::isPattern(format.at(pos), count) ? stringify(format.at(pos), count) : format.substr(pos, count));
676 return DateTime(std::chrono::system_clock::now());
689 static DateTime fromString(
const std::string& datetime,
const std::string& format =
"yyyy-MM-dd hh:mm:ss")
700 for (
size_t fmtPos = 0; fmtPos < format.size(); ++fmtPos) {
701 const auto count = internal::countIdenticalCharsFrom(fmtPos, format);
702 if (internal::isPattern(format[fmtPos])) {
703 if (!internal::isPattern(format[fmtPos], count)) {
707 if (format[fmtPos] ==
'y') {
708 y = parse(format[fmtPos], count, datetime, dtPos);
709 }
else if (format[fmtPos] ==
'#' || format[fmtPos] ==
'E') {
710 sign = parse(format[fmtPos], count, datetime, dtPos);
711 }
else if (format[fmtPos] ==
'M') {
712 M = parse(format[fmtPos], count, datetime, dtPos);
713 }
else if (format[fmtPos] ==
'd') {
715 parse(format[fmtPos], count, datetime, dtPos);
717 d = parse(format[fmtPos], count, datetime, dtPos);
719 }
else if (format[fmtPos] ==
'h' || format[fmtPos] ==
'H') {
720 h = parse(format[fmtPos], count, datetime, dtPos);
721 }
else if (format[fmtPos] ==
'a' || format[fmtPos] ==
'A') {
722 int clock = parse(format[fmtPos], count, datetime, dtPos);
723 h += clock == -12 && h >= 12 || clock == 12 && h < 12 ? clock : 0;
724 }
else if (format[fmtPos] ==
'm') {
725 m = parse(format[fmtPos], count, datetime, dtPos);
726 }
else if (format[fmtPos] ==
's') {
727 s = parse(format[fmtPos], count, datetime, dtPos);
728 }
else if (format[fmtPos] ==
'f') {
729 f = parse(format[fmtPos], count, datetime, dtPos) * std::pow(10, 9 - count);
733 if (dtPos == std::string::npos) {
744 const long integer =
static_cast<long>(julianDay);
745 const double fraction = julianDay - integer;
746 const long millisecondCount =
static_cast<long>(
static_cast<double>(
Milliseconds(
Days(1)).count()) * fraction);
807 std::string stringify(
char flag,
size_t count)
const
809 std::stringstream output;
810 output << std::setfill(
'0') << std::setw(count);
812 output << (
year() < 0 ?
"-" :
"+");
813 }
else if (flag ==
'E') {
814 output << (
year() < 0 ?
"BCE" :
"CE");
815 }
else if (flag ==
'y') {
816 const int y = std::abs(
year());
819 }
else if (count == 2) {
820 output << y - (y / 100 * 100);
821 }
else if (count == 4) {
822 output << y - (y / 10000 * 10000);
824 }
else if (flag ==
'M') {
825 if (count == 1 || count == 2) {
827 }
else if (count == 3) {
828 output << internal::getShortMonthName(
month());
829 }
else if (count == 4) {
830 output << internal::getLongMonthName(
month());
832 }
else if (flag ==
'd') {
833 if (count == 1 || count == 2) {
835 }
else if (count == 3) {
836 output << internal::getShortWeekdayName(
dayOfWeek());
837 }
else if (count == 4) {
838 output << internal::getLongWeekdayName(
dayOfWeek());
840 }
else if (flag ==
'h') {
842 }
else if (flag ==
'H') {
844 output << (h == 0 ? 12 : h > 12 ? h - 12
846 }
else if (flag ==
'm') {
848 }
else if (flag ==
's') {
850 }
else if (flag ==
'f') {
851 output <<
nanosecond() /
static_cast<long>(std::pow(10, 9 - count));
852 }
else if (flag ==
'a') {
853 output << (
hour() < 12 ?
"am" :
"pm");
854 }
else if (flag ==
'A') {
855 output << (
hour() < 12 ?
"AM" :
"PM");
860 static int parse(
char flag,
size_t count, std::string input,
size_t& pos)
862 if (flag ==
'y' || (flag ==
'M' || flag ==
'd' || flag ==
'h' || flag ==
'H' || flag ==
'm' || flag ==
's') && count <= 2 || flag ==
'f') {
863 if (pos < input.size() && std::isdigit(input[pos])) {
864 return internal::readIntAndAdvancePos(input, pos, flag ==
'f' ? count : (flag ==
'y' && count == 1 || count == 4 ? 4 : 2));
866 }
else if (flag ==
'#') {
867 if (pos < input.size() && (input[pos] ==
'-' || input[pos] ==
'+')) {
868 return (input[pos++] ==
'-' ? -1 : 1);
870 }
else if (flag ==
'E') {
871 if (pos + 2 < input.size() && input.substr(pos, 3) ==
"BCE") {
874 }
else if (pos + 1 < input.size() && input.substr(pos, 2) ==
"CE") {
878 }
else if ((flag ==
'M' || flag ==
'd') && count <= 4 && pos + 2 < input.size()) {
879 const auto& line = count == 3 ? input.substr(pos, 3) : input.substr(pos);
881 const auto& monthNameArray = count == 3 ? internal::getShortMonthNameArray() : internal::getLongMonthNameArray();
882 size_t index = internal::search(monthNameArray, line);
883 if (index < monthNameArray.size()) {
884 pos += monthNameArray[index].size();
888 const auto& weekdayNameArray = count == 3 ? internal::getShortWeekdayNameArray() : internal::getLongWeekdayNameArray();
889 size_t index = internal::search(weekdayNameArray, line);
890 if (index < weekdayNameArray.size()) {
891 pos += weekdayNameArray[index].size();
895 }
else if ((flag ==
'a' || flag ==
'A') && pos + 1 < input.size()) {
896 if (flag ==
'a' && input.substr(pos, 2) ==
"am" || input.substr(pos, 2) ==
"AM") {
898 }
else if (flag ==
'a' && input.substr(pos, 2) ==
"pm" || input.substr(pos, 2) ==
"PM") {
902 pos = std::string::npos;
903 return std::numeric_limits<int>::min();
919 os << dt.
toString(
"yyyy-MM-ddThh:mm:ss.fff");
927 const int DateTimeFormatWidth = 23;
928 char result[DateTimeFormatWidth];
929 is.read(result, DateTimeFormatWidth);
DateTime is an immutable class representing a datetime without a time zone in the ISO-8601 calendar s...
Definition: datetime.hpp:47
DateTime subtractMicroseconds(int microseconds) const
Returns a new DateTime object representing this datetime with microseconds subtracted from it.
Definition: datetime.hpp:408
DateTime subtractDuration(const Duration &duration) const
Returns a new DateTime object representing this datetime with duration subtracted from it.
Definition: datetime.hpp:508
DateTime operator+(const Duration &duration) const
Returns the result of adding duration to this datetime as a new DateTime object.
Definition: datetime.hpp:202
bool operator<(const DateTime &other) const
Returns whether this datetime is earlier than other.
Definition: datetime.hpp:147
DateTime operator-(const Duration &duration) const
Returns the result of subtracting duration from this datetime as a new DateTime object.
Definition: datetime.hpp:196
DateTime subtractHours(int hours) const
Returns a new DateTime object representing this datetime with hours subtracted from it.
Definition: datetime.hpp:456
Date date() const
Returns the date part of this datetime.
Definition: datetime.hpp:220
Time::Seconds Seconds
Second duration.
Definition: datetime.hpp:59
static long long secondsBetween(const DateTime &from, const DateTime &to)
Returns the number of seconds between from and to.
Definition: datetime.hpp:775
DateTime addNanoseconds(int nanoseconds) const
Returns a new DateTime object representing this datetime with nanoseconds added to it.
Definition: datetime.hpp:390
Microseconds toStdDurationSinceEpoch() const
Returns a std::chrono::microseconds duration since "1970-01-01 00:00:00.000 UTC", not counting leap s...
Definition: datetime.hpp:566
std::time_t toScalarStdTime() const
Returns a std::time_t representation of this datetime.
Definition: datetime.hpp:594
static long hoursBetween(const DateTime &from, const DateTime &to)
Returns the number of hours between from and to.
Definition: datetime.hpp:787
DateTime()=default
Constructs an invalid DateTime object with every field set to zero.
int year() const
Returns the year as a number. There is no year 0. Negative numbers indicate years before 1 CE; that i...
Definition: datetime.hpp:280
long microsecond() const
Returns the microsecond of second (0, 999999).
Definition: datetime.hpp:238
std::tm toBrokenStdTime() const
Returns a std::tm representation of this datetime.
Definition: datetime.hpp:578
static DateTime fromJulianDay(double julianDay)
Returns a DateTime object corresponding to the Julian day julianDay. See toJulianDay() for informatio...
Definition: datetime.hpp:742
DateTime addMinutes(int minutes) const
Returns a new DateTime object representing this datetime with minutes added to it.
Definition: datetime.hpp:438
void getYearMonthDay(int *year, int *month, int *day) const
Set the year, month, and day in the parameters year, month, and day, respectively.
Definition: datetime.hpp:286
std::string dayOfWeekName(bool shortName=false) const
Returns the name of the weekday of this datetime.
Definition: datetime.hpp:351
std::istream & operator>>(std::istream &is, DateTime &dt)
Reads a datetime in ISO-8601 date and time format "yyyy-MM-ddThh:mm:ss.fff" from stream is and stores...
Definition: datetime.hpp:925
long nanosecond() const
Returns the nanosecond of second (0, 999999999).
Definition: datetime.hpp:232
int day() const
Returns the day of month (1, 31).
Definition: datetime.hpp:268
std::string toString(const std::string &format="yyyy-MM-dd hh:mm:ss") const
Returns the datetime as a string formatted according to the format string format.
Definition: datetime.hpp:655
bool operator==(const DateTime &other) const
Returns whether this datetime is equal to other.
Definition: datetime.hpp:171
Nanoseconds operator-(const DateTime &other) const
Returns the result of subtracting other from this datetime as Nanoseconds duration.
Definition: datetime.hpp:190
int dayOfWeek() const
Returns the weekday as a number between 1 and 7, which corresponds to the enumeration Weekday.
Definition: datetime.hpp:292
double toJulianDay() const
Returns the corresponding Julian Day Number (JDN) of this datetime as a double, where the integral pa...
Definition: datetime.hpp:607
DateTime addMicroseconds(int microseconds) const
Returns a new DateTime object representing this datetime with microseconds added to it.
Definition: datetime.hpp:402
static DateTime epoch()
Returns a DateTime object set to the epoch "1970-1-1T00:00:00".
Definition: datetime.hpp:680
static DateTime fromString(const std::string &datetime, const std::string &format="yyyy-MM-dd hh:mm:ss")
Returns a DateTime object from the string datetime formatted according to the format string format.
Definition: datetime.hpp:689
bool operator!=(const DateTime &other) const
Returns whether this datetime is different from other.
Definition: datetime.hpp:177
std::ostream & operator<<(std::ostream &os, const DateTime &dt)
Writes dt to stream os in ISO-8601 date and time format "yyyy-MM-ddThh:mm:ss.fff"....
Definition: datetime.hpp:917
std::string monthName(bool shortName=false) const
Returns the name of the month of this datetime.
Definition: datetime.hpp:377
static long long millisecondsBetween(const DateTime &from, const DateTime &to)
Returns the number of milliseconds between from and to.
Definition: datetime.hpp:769
int minute() const
Returns the minute of hour (0, 59).
Definition: datetime.hpp:256
Time::Nanoseconds Nanoseconds
Nanosecond duration.
Definition: datetime.hpp:56
DateTime addYears(int years) const
Returns a new DateTime object representing this datetime with years added to it.
Definition: datetime.hpp:486
DateTime(const Date &date)
Constructs a DateTime object from date, leaving the time part at midnight ("00:00:00").
Definition: datetime.hpp:110
int daysInMonth() const
Returns the number of days in the current month. It ranges between 28 and 31.
Definition: datetime.hpp:304
DateTime addDuration(const Duration &duration) const
Returns a new DateTime object representing this datetime with duration added to it.
Definition: datetime.hpp:498
Time::Hours Hours
Hour duration.
Definition: datetime.hpp:61
Time::Minutes Minutes
Minute duration.
Definition: datetime.hpp:60
DateTime subtractYears(int years) const
Returns a new DateTime object representing this datetime with years subtracted from it.
Definition: datetime.hpp:492
DateTime addSeconds(int seconds) const
Returns a new DateTime object representing this datetime with seconds added to it.
Definition: datetime.hpp:426
DateTime addDays(int days) const
Returns a new DateTime object representing this datetime with days added to it.
Definition: datetime.hpp:462
DateTime(const std::chrono::system_clock::time_point &timePoint)
Constructs a DateTime object from the standard library's chrono time point, timePoint.
Definition: datetime.hpp:104
DateTime subtractDays(int days) const
Returns a new DateTime object representing this datetime with days subtracted from it.
Definition: datetime.hpp:468
DateTime addMonths(int months) const
Returns a new DateTime object representing this datetime with months added to it. See Date::addMonths...
Definition: datetime.hpp:474
DateTime(const Date &date, const Time &time)
Constructs a DateTime object from date and time.
Definition: datetime.hpp:117
long long toMillisecondsSinceEpoch() const
Returns the number of elapsed milliseconds since "1970-01-01 00:00:00.000 UTC", not counting leap sec...
Definition: datetime.hpp:536
DateTime subtractMilliseconds(int milliseconds) const
Returns a new DateTime object representing this datetime with milliseconds subtracted from it.
Definition: datetime.hpp:420
long long toNanosecondsSinceEpoch() const
Returns the number of elapsed nanoseconds since "1970-01-01 00:00:00.000 UTC", not counting leap seco...
Definition: datetime.hpp:524
long long toMicrosecondsSinceEpoch() const
Returns the number of elapsed microseconds since "1970-01-01 00:00:00.000 UTC", not counting leap sec...
Definition: datetime.hpp:530
int weekOfYear(int *weekYear=nullptr) const
Returns the week number of the year of this datetime, and optionally stores the year in weekYear.
Definition: datetime.hpp:330
bool isValid() const
Returns whether this datetime object represents a valid datetime. A DateTime object is valid if both ...
Definition: datetime.hpp:214
static long long microsecondsBetween(const DateTime &from, const DateTime &to)
Returns the number of microseconds between from and to.
Definition: datetime.hpp:763
DateTime subtractSeconds(int seconds) const
Returns a new DateTime object representing this datetime with seconds subtracted from it.
Definition: datetime.hpp:432
int millisecond() const
Returns the millisecond of second (0, 999).
Definition: datetime.hpp:244
~DateTime()=default
Default destructor.
static long minutesBetween(const DateTime &from, const DateTime &to)
Returns the number of minutes between from and to.
Definition: datetime.hpp:781
DateTime(const Duration &duration)
Constructs a DateTime object from duration since the epoch "1970-01-01 00:00:00 UTC".
Definition: datetime.hpp:95
DateTime & operator=(const DateTime &other)=default
Copy assignment operator.
Date::Days Days
Day duration.
Definition: datetime.hpp:62
DateTime addMilliseconds(int milliseconds) const
Returns a new DateTime object representing this datetime with milliseconds added to it.
Definition: datetime.hpp:414
static DateTime current()
Returns a DateTime object set to the current datetime obtained from the system clock.
Definition: datetime.hpp:674
DateTime addHours(int hours) const
Returns a new DateTime object representing this datetime with hours added to it.
Definition: datetime.hpp:450
static long long nanosecondsBetween(const DateTime &from, const DateTime &to)
Returns the number of nanoseconds between from and to.
Definition: datetime.hpp:757
long long toSecondsSinceEpoch() const
Returns the number of elapsed seconds since "1970-01-01 00:00:00.000 UTC, not counting leap seconds.
Definition: datetime.hpp:542
int second() const
Returns the second of minute (0, 59).
Definition: datetime.hpp:250
bool isLeapYear() const
Returns whether the year of this datetime is a leap year. For more information, see Date::isLeapYear(...
Definition: datetime.hpp:316
long toMinutesSinceEpoch() const
Returns the number of elapsed minutes since "1970-01-01 00:00:00.000 UTC, not counting leap seconds.
Definition: datetime.hpp:548
DateTime & operator=(DateTime &&other)=default
Move assignment operator.
DateTime subtractMonths(int months) const
Returns a new DateTime object representing this datetime with months subtracted from it....
Definition: datetime.hpp:480
static long daysBetween(const DateTime &from, const DateTime &to)
Returns the number of days between from and to.
Definition: datetime.hpp:793
DateTime subtractNanoseconds(int nanoseconds) const
Returns a new DateTime object representing this datetime with nanoseconds subtracted from it.
Definition: datetime.hpp:396
bool operator<=(const DateTime &other) const
Returns whether this datetime is earlier than other or equal to it.
Definition: datetime.hpp:153
long toDaysSinceEpoch() const
Returns the number of elapsed days since "1970-01-01 00:00:00.000 UTC", not counting leap seconds.
Definition: datetime.hpp:560
Time::Microseconds Microseconds
Microsecond duration.
Definition: datetime.hpp:57
DateTime(DateTime &&other)=default
Move-constructs a DateTime object from other.
Time::Milliseconds Milliseconds
Millisecond duration.
Definition: datetime.hpp:58
DateTime(const DateTime &other)=default
Copy-constructs a DateTime object from other.
int daysInYear() const
Returns the number of days in the current year. It is either 365 or 366.
Definition: datetime.hpp:310
int hour() const
Returns the hour of day (0, 23).
Definition: datetime.hpp:262
Date::Weeks Weeks
Week duration.
Definition: datetime.hpp:63
bool operator>=(const DateTime &other) const
Returns whether this datetime is later than other or equal to it.
Definition: datetime.hpp:165
Time time() const
Returns the time part of this datetime.
Definition: datetime.hpp:226
bool operator>(const DateTime &other) const
Returns whether this datetime is later than other.
Definition: datetime.hpp:159
static long weeksBetween(const DateTime &from, const DateTime &to)
Returns the number of weeks between from and to.
Definition: datetime.hpp:799
int month() const
Returns the month of year (1, 12), which corresponds to the enumeration Month.
Definition: datetime.hpp:274
DateTime subtractMinutes(int minutes) const
Returns a new DateTime object representing this datetime with minutes subtracted from it.
Definition: datetime.hpp:444
std::chrono::system_clock::time_point toStdTimePoint() const
Returns a std::chrono::system_clock::time_point representation of this datetime.
Definition: datetime.hpp:572
long toHoursSinceEpoch() const
Returns the number of elapsed hours since "1970-01-01 00:00:00.000 UTC, not counting leap seconds.
Definition: datetime.hpp:554
int dayOfYear() const
Returns the day of the year as a number between 1 and 365 (1 to 366 on leap years).
Definition: datetime.hpp:298
Date is an immutable class representing a date without a time zone in the ISO-8601 calendar system,...
Definition: date.hpp:84
std::string monthName(bool shortName=false) const
Returns the name of the month of this date.
Definition: date.hpp:393
Date subtractDays(int days) const
Returns the result of subtracting days from this date as a new Date object.
Definition: date.hpp:414
int dayOfWeek() const
Returns the weekday of this date as a number between 1 and 7, which corresponds to the enumeration We...
Definition: date.hpp:286
long toDaysSinceEpoch() const
Returns the number of elapsed days since the epoch "1970-01-01".
Definition: date.hpp:486
Month
Type of month.
Definition: date.hpp:119
int daysInYear() const
Returns the number of days in the year of this date. It is either 365 or 366.
Definition: date.hpp:304
bool isValid() const
Returns whether this date object represents a valid date.
Definition: date.hpp:248
internal::Days Days
Day duration.
Definition: date.hpp:91
void getYearMonthDay(int *year, int *month, int *day) const
Set the year, month, and day of this date in the parameters year, month, and day, respectively.
Definition: date.hpp:254
Date subtractYears(int years) const
Returns the result of subtracting years from this date as a new Date object.
Definition: date.hpp:472
int year() const
Returns the year of this date as a number.
Definition: date.hpp:280
std::chrono::duration< long, std::ratio_multiply< std::ratio< 7 >, Days::period > > Weeks
Week duration.
Definition: date.hpp:92
int daysInMonth() const
Returns the number of days in the month of this date. It ranges between 28 and 31.
Definition: date.hpp:298
Date addYears(int years) const
Returns the result of adding years to this date as a new Date object.
Definition: date.hpp:465
Date subtractMonths(int months) const
Returns the result of subtracting months from this date as a new Date object.
Definition: date.hpp:451
Weekday
Type of weekday.
Definition: date.hpp:105
Date addDays(int days) const
Returns the result of adding days to this date as a new Date object.
Definition: date.hpp:406
std::string dayOfWeekName(bool shortName=false) const
Returns the name of the weekday of this date.
Definition: date.hpp:367
int month() const
Returns the month of the year of this date as a number between 1 and 12, which corresponds to the enu...
Definition: date.hpp:271
static Date epoch()
Returns a Date object set to the epoch "1970-01-01".
Definition: date.hpp:603
int day() const
Returns the day of the month of this date as a number between 1 and 31.
Definition: date.hpp:265
Days toStdDurationSinceEpoch() const
Returns the elapsed time since the epoch "1970-01-01" as a Days duration.
Definition: date.hpp:492
int weekOfYear(int *weekYear=nullptr) const
Returns the week of the year of this date, and optionally stores the year in weekYear.
Definition: date.hpp:324
int dayOfYear() const
Returns the day of year of this date as a number between 1 and 365 (1 to 366 on leap years).
Definition: date.hpp:292
bool isLeapYear() const
Returns whether the year of this date is a leap year.
Definition: date.hpp:310
Time is an immutable time class representing a time without a time zone in the ISO-8601 calendar syst...
Definition: time.hpp:46
long nanosecond() const
Returns the nanosecond of second (0, 999999999).
Definition: time.hpp:263
int minute() const
Returns the minute of hour (0, 59).
Definition: time.hpp:287
int millisecond() const
Returns the millisecond of second (0, 999).
Definition: time.hpp:275
int hour() const
Returns the hour of day (0, 23).
Definition: time.hpp:293
std::chrono::milliseconds Milliseconds
Millisecond duration.
Definition: time.hpp:58
std::chrono::minutes Minutes
Minute duration.
Definition: time.hpp:60
long microsecond() const
Returns the microsecond of second (0, 999999).
Definition: time.hpp:269
std::chrono::microseconds Microseconds
Microsecond duration.
Definition: time.hpp:57
bool isValid() const
Returns whether this time object represents a valid time.
Definition: time.hpp:257
long long toNanosecondsSinceMidnight() const
Returns the elapsed nanoseconds since midnight.
Definition: time.hpp:397
std::chrono::nanoseconds Nanoseconds
Nanosecond duration.
Definition: time.hpp:56
Nanoseconds toStdDurationSinceMidnight() const
Returns the elapsed time since midnight as a Nanoseconds duration.
Definition: time.hpp:433
std::chrono::seconds Seconds
Second duration.
Definition: time.hpp:59
std::chrono::hours Hours
Hour duration.
Definition: time.hpp:61
static Time midnight()
Returns a Time object set to midnight (i.e., "00:00:00").
Definition: time.hpp:535
int second() const
Returns the second of minute (0, 59).
Definition: time.hpp:281