28 m_hh(
std::min(23,
std::max(0,hh))) ,
29 m_mm(
std::min(59,
std::max(0,mm))) ,
30 m_ss(
std::min((hh==23&&mm==59)?60:59,
std::max(0,ss)))
35 Time(tm.hour(),tm.min(),tm.sec())
88std::string G::Time::xx(
int n )
90 return std::string(1U,
char(
'0'+n/10)).append(1U,
char(
'0'+n%10)) ;
95 if( sep ==
nullptr ) sep =
"" ;
96 return std::string(xx(m_hh)).append(sep).append(xx(m_mm)).append(sep).append(xx(m_ss)) ;
102 if( sep ==
nullptr ) sep =
"" ;
103 return std::string(xx(m_hh)).append(sep).append(xx(m_mm)) ;
118 static_cast<unsigned int>(std::max(0,std::min(23,m_hh))) * 3600U +
119 static_cast<unsigned int>(std::max(0,std::min(59,m_mm))) * 60U +
120 static_cast<unsigned int>(std::max(0,std::min(59,m_ss))) ;
127 unsigned int hh = s / 3600U ;
128 unsigned int mm_ss = s - (hh*3600U) ;
130 std::max(0,std::min(23,
static_cast<int>(hh))) ,
131 std::max(0,std::min(59,
static_cast<int>(mm_ss/60U))) ,
132 std::max(0,std::min(59,
static_cast<int>(mm_ss%60U))) } ;
138 return m_hh == other.m_hh && m_mm == other.m_mm && m_ss == other.m_ss ;
144 return !(*
this==other) ;
An encapsulation of 'struct std::tm'.
Represents a unix-epoch time with microsecond resolution.
An overload discriminator class for Time constructors.
A simple time-of-day (hh/mm/ss) class.
bool operator==(const Time &) const
Comparison operator.
unsigned int value() const
Returns the time as the number of seconds since midnight (ignoring leap seconds).
int minutes() const
Returns the minutes (0 <= m < 60).
static Time at(unsigned int)
Factory function for a time that is the given number of seconds since midnight (see value()).
std::string hhmm(const char *sep=nullptr) const
Returns the hhmm string.
int hours() const
Returns the hours (0 <= h < 24).
Time()
Constructor for the current time, using UTC.
std::string ss() const
Returns the seconds as a two-digit decimal string.
int seconds() const
Returns the seconds (0 <= s <= 61).
bool operator!=(const Time &) const
Comparison operator.
std::string hhmmss(const char *sep=nullptr) const
Returns the hhmmss string.