37 class BrokenDownTime ;
64 void format( std::vector<char> & out ,
const char * fmt )
const ;
70 std::string
str(
const char * fmt )
const ;
74 std::string
str()
const ;
113 std::time_t epochTimeFromUtcImp(
bool & , std::time_t & )
const ;
114 std::time_t epochTimeFromUtcImp()
const ;
117 friend class G::DateTimeTest ;
118 struct std::tm m_tm{} ;
133 explicit SystemTime( std::time_t ,
unsigned long us = 0UL ) noexcept ;
148 unsigned int ms()
const ;
151 unsigned int us()
const ;
154 std::time_t
s()
const noexcept ;
198 friend class G::DateTimeTest ;
199 using duration_type = std::chrono::system_clock::duration ;
200 using time_point_type = std::chrono::time_point<std::chrono::system_clock> ;
205 time_point_type m_tp ;
221 bool isZero()
const noexcept ;
265 friend class G::DateTimeTest ;
266 using duration_type = std::chrono::steady_clock::duration ;
267 using time_point_type = std::chrono::time_point<std::chrono::steady_clock> ;
270 unsigned long test_s()
const ;
271 unsigned long test_us()
const ;
275 time_point_type m_tp ;
291 using s_type =
unsigned int ;
292 using us_type =
unsigned int ;
311 unsigned int s()
const ;
314 unsigned int us()
const ;
352 static void increase(
unsigned int &
s ,
unsigned int ds = 1U ) ;
353 static void decrease(
unsigned int &
s ,
unsigned int ds = 1U ) ;
362 std::ostream & operator<<( std::ostream & ,
const SystemTime & ) ;
363 std::ostream & operator<<( std::ostream & ,
const TimeInterval & ) ;
372 G_EXCEPTION_CLASS( Error ,
"date/time error" ) ;
373 using Offset = std::pair<bool,unsigned int> ;
An encapsulation of 'struct std::tm'.
int wday() const
Returns week day where sunday=0 and saturday=6.
int day() const
Returns the 1..31 month-day value.
std::time_t epochTimeFromLocal() const
Uses std::mktime() to convert this locale-dependent local broken-down time into epoch time.
bool sameMinute(const BrokenDownTime &other) const
Returns true if this and the other broken-down times are the same, at minute resolution with no round...
std::string str() const
Returns str() using a "%F %T" format.
int sec() const
Returns the 0..59 or 0..60 seconds value.
static BrokenDownTime utc(SystemTime)
Factory function for the utc time of the given epoch time.
static BrokenDownTime midday(int year, int month, int day)
Factory function for midday on the given date.
int month() const
Returns the 1..12 month value.
void format(std::vector< char > &out, const char *fmt) const
Puts the formatted date, including a terminating null character, into the given buffer.
static BrokenDownTime local(SystemTime)
Factory function for the locale-dependent local time of the given epoch time.
int hour() const
Returns the 0..23 hour value.
int year() const
Returns the four-digit year value.
std::time_t epochTimeFromUtc() const
Searches std::mktime() over the range of all timezones to convert this utc broken-down time into epoc...
int min() const
Returns the 0..59 minute value.
A static class that knows about timezone offsets.
static Offset offset(SystemTime)
Returns the offset in seconds between UTC and localtime as at the given system time.
static std::string offsetString(Offset offset)
Converts the given utc/localtime offset into a five-character "+/-hhmm" string.
Represents a unix-epoch time with microsecond resolution.
TimeInterval operator-(const SystemTime &start) const
Returns the given start time's interval() compared to this end time.
static SystemTime now()
Factory function for the current time.
std::time_t s() const noexcept
Returns the number of seconds since the start of the epoch.
SystemTime operator+(TimeInterval) const
Returns this time with given interval added.
unsigned int ms() const
Returns the millisecond fraction.
unsigned int us() const
Returns the microsecond fraction.
bool operator!=(const SystemTime &) const
Comparison operator.
BrokenDownTime local() const
Returns the locale-dependent local broken-down time.
bool operator>(const SystemTime &) const
Comparison operator.
void streamOut(std::ostream &) const
Streams out the time comprised of the s() value, a decimal point, and then the six-digit us() value.
TimeInterval interval(const SystemTime &end) const
Returns the interval between this time and the given end time.
bool sameSecond(const SystemTime &other) const noexcept
Returns true if this time and the other time are the same, at second resolution.
bool operator<=(const SystemTime &) const
Comparison operator.
bool operator>=(const SystemTime &) const
Comparison operator.
static SystemTime zero()
Factory function for the start of the epoch.
SystemTime(std::time_t, unsigned long us=0UL) noexcept
Constructor.
BrokenDownTime utc() const
Returns the utc broken-down time.
void operator+=(TimeInterval)
Adds the given interval. Throws on overflow.
bool operator<(const SystemTime &) const
Comparison operator.
bool operator==(const SystemTime &) const
Comparison operator.
An interval between two G::SystemTime values or two G::TimerTime values.
TimeInterval(unsigned int s, unsigned int us=0U)
Constructor.
TimeInterval operator+(const TimeInterval &) const
Returns the combined interval. Throws on overflow.
static TimeInterval zero()
Factory function for the zero interval.
void operator-=(TimeInterval)
Subtracts the given interval. Throws on underflow.
bool operator==(const TimeInterval &) const
Comparison operator.
static TimeInterval limit()
Factory function for the maximum valid interval.
unsigned int s() const
Returns the number of seconds.
unsigned int us() const
Returns the fractional microseconds part.
void operator+=(TimeInterval)
Adds the given interval. Throws on overflow.
bool operator>(const TimeInterval &) const
Comparison operator.
TimeInterval operator-(const TimeInterval &) const
Returns the interval difference. Throws on underflow.
bool operator<(const TimeInterval &) const
Comparison operator.
bool operator!=(const TimeInterval &) const
Comparison operator.
void streamOut(std::ostream &) const
Streams out the interval.
bool operator>=(const TimeInterval &) const
Comparison operator.
bool operator<=(const TimeInterval &) const
Comparison operator.
A monotonically increasing subsecond-resolution timestamp, notionally unrelated to time_t.
bool isZero() const noexcept
Returns true if zero().
static TimerTime now()
Factory function for the current steady-clock time.
TimerTime operator+(const TimeInterval &) const
Returns this time with given interval added.
bool operator>(const TimerTime &) const
Comparison operator.
TimeInterval interval(const TimerTime &end) const
Returns the interval between this time and the given end time.
bool operator==(const TimerTime &) const
Comparison operator.
bool operator!=(const TimerTime &) const
Comparison operator.
TimeInterval operator-(const TimerTime &start) const
Returns the given start time's interval() compared to this end time.
bool sameSecond(const TimerTime &other) const
Returns true if this time and the other time are the same, at second resolution.
void operator+=(TimeInterval)
Adds an interval.
static TimerTime zero()
Factory function for the start of the epoch.
bool operator<(const TimerTime &) const
Comparison operator.
bool operator<=(const TimerTime &) const
Comparison operator.
bool operator>=(const TimerTime &) const
Comparison operator.