9 #ifndef CPPCOMMON_TIME_TIME_H
10 #define CPPCOMMON_TIME_TIME_H
34 template <
class TOutputStream>
67 ~
Time() noexcept = default;
96 {
return time ==
Time(timestamp); }
98 {
return Time(timestamp) == time; }
102 {
return time !=
Time(timestamp); }
104 {
return Time(timestamp) != time; }
108 {
return time >
Time(timestamp); }
110 {
return Time(timestamp) > time; }
114 {
return time <
Time(timestamp); }
116 {
return Time(timestamp) < time; }
120 {
return time >=
Time(timestamp); }
122 {
return Time(timestamp) >= time; }
126 {
return time <=
Time(timestamp); }
128 {
return Time(timestamp) <= time; }
132 std::chrono::time_point<std::chrono::system_clock>
chrono()
const
168 {
return Time(1970, 1, 1); }
225 template <
class Clock,
class Duration>
251 template <
class Clock,
class Duration>
LocalTime(const std::chrono::time_point< Clock, Duration > &time_point)
Initialize local time with a given std::chrono time point.
LocalTime(const Time &time)
Initialize local time with another time value.
LocalTime()
Initialize local time with a current value.
friend bool operator>(const Timestamp ×tamp, const Time &time)
Time & operator-=(const Timespan &offset)
Time() noexcept
Initialize time with an epoch time.
int month() const noexcept
Get month value (1-12)
friend bool operator<=(const Time &time, const Timestamp ×tamp)
friend bool operator<(const Time &time, const Timestamp ×tamp)
friend bool operator<(const Timestamp ×tamp, const Time &time)
Time & operator=(const Time &) noexcept=default
friend bool operator!=(const Timestamp ×tamp, const Time &time)
LocalTimestamp localstamp() const
Get local timestamp from the current date & time value.
int year() const noexcept
Get year value (1970-2038 for 32-bit or 1970-3000 for 64-bit)
Time & operator=(Time &&) noexcept=default
friend bool operator<=(const Timestamp ×tamp, const Time &time)
int millisecond() const noexcept
Get millisecond value (0-999)
friend Time operator-(const Time &time, const Timespan &offset)
void swap(Time &time) noexcept
Swap two instances.
friend Time operator-(const Timespan &offset, const Time &time)
std::chrono::time_point< std::chrono::system_clock > chrono() const
Convert date & time to the std::chrono time point.
friend Time operator+(const Timespan &offset, const Time &time)
static Time epoch()
Get the epoch date & time.
Time & operator=(const Timestamp ×tamp)
friend bool operator!=(const Time &time, const Timestamp ×tamp)
friend Timespan operator-(const Time &time1, const Time &time2)
int day() const noexcept
Get day value (1-31)
int minute() const noexcept
Get minute value (0-59)
int second() const noexcept
Get second value (0-59)
friend bool operator==(const Time &time, const Timestamp ×tamp)
Weekday weekday() const noexcept
Get weekday.
int hour() const noexcept
Get hour value (0-23)
int _weekday
Weekday value.
int _millisecond
Millisecond value.
UtcTimestamp utcstamp() const
Get UTC timestamp from the current date & time value.
int microsecond() const noexcept
Get microsecond value (0-999)
Time(const Time &) noexcept=default
friend Time operator+(const Time &time, const Timespan &offset)
friend bool operator==(const Timestamp ×tamp, const Time &time)
friend bool operator>=(const Timestamp ×tamp, const Time &time)
int _nanosecond
Nanosecond value.
friend bool operator>=(const Time &time, const Timestamp ×tamp)
int nanosecond() const noexcept
Get nanosecond value (0-999)
Time(Time &&) noexcept=default
int _microsecond
Microsecond value.
friend bool operator>(const Time &time, const Timestamp ×tamp)
std::chrono::system_clock::time_point chrono() const noexcept
Convert timestamp to the std::chrono time point.
UtcTime(const Time &time)
Initialize UTC time with another time value.
UtcTime(const std::chrono::time_point< Clock, Duration > &time_point)
Initialize UTC time with a given std::chrono time point.
UtcTime()
Initialize UTC time with a current value.
C++ Common project definitions.
std::ostream & operator<<(std::ostream &os, const uint128_t &value)
Time inline implementation.