1 #ifndef GAUDIKERNEL_TIME_ICPP
2 #define GAUDIKERNEL_TIME_ICPP 1
13 inline Time::Time (ValueType nsecs): m_nsecs(nsecs) {
26 : m_nsecs(secs * Time::SEC_NSECS + nsecs) {
59 return 0x7fffffffffffffffLL;
64 return ((year % 4) == 0
66 || (year % 400) == 0));
90 : m_nsecs(secs * Time::SEC_NSECS + nsecs) {}
176 m_nsecs /= x.m_nsecs;
return *
this;
181 m_nsecs %= x.m_nsecs;
return *
this;
225 return t1.
ns() == t2.
ns();
229 return t1.
ns() != t2.
ns();
233 return t1.
ns() < t2.
ns();
237 return t1.
ns() <= t2.
ns();
241 return t1.
ns() > t2.
ns();
245 return t1.
ns() >= t2.
ns();
285 return t1.
ns() == t2.
ns();
289 return t1.
ns() != t2.
ns();
293 return t1.
ns() < t2.
ns();
297 return t1.
ns() <= t2.
ns();
301 return t1.
ns() > t2.
ns();
305 return t1.
ns() >= t2.
ns();
ValueType seconds(void) const
Get the number of complete seconds in the span.
ValueType ns(void) const
Return the time span as nanoseconds.
GAUDI_API std::ostream & operator<<(std::ostream &o, const Gaudi::Histo1DDef &histo)
the streamer operator for class Gaudi::Histo1DDef
bool operator!=(const Gaudi::Time &t1, const Gaudi::Time &t2)
static const ValueType SEC_NSECS
Nanoseconds in one second.
TimeSpan & operator/=(const TimeSpan &n)
Divide a time span.
The stream buffer is a small object collecting object data.
StreamBuffer & operator>>(StreamBuffer &s, Gaudi::Time &t)
int days(void) const
Get the number of complete days in the span.
int lastMinutes(void) const
Get the number of complete minutes in the last incomplete hour of the span.
bool operator==(const Gaudi::Time &t1, const Gaudi::Time &t2)
int lastNSeconds(void) const
Get the number of nanoseconds in the last incomplete second of the span.
static const int SECS_PER_DAY
Seconds in 24 hours.
void TimeAssert(bool cond, const std::string &msg="time assertion failed") const
TimeSpan & operator*=(const TimeSpan &n)
Multiply a time span.
StreamBuffer & operator<<(StreamBuffer &s, const Gaudi::Time &t)
int lastSeconds(void) const
Get the number of complete seconds in the last incomplete minute of the span.
Gaudi::Time operator+(const Gaudi::Time &t, const Gaudi::TimeSpan &ts)
ValueType ns(void) const
Return the time as nanoseconds since 00:00:00 on January 1, 1970 in UTC.
static const int SECS_PER_HOUR
Seconds in one hour hour.
Gaudi::TimeSpan operator-(const Gaudi::Time &t1, const Gaudi::Time &t2)
TimeSpan & operator+=(const TimeSpan &x)
Add to a time span.
TimeSpan & operator-=(const TimeSpan &x)
Subtract from a time span.
bool operator>(const Gaudi::Time &t1, const Gaudi::Time &t2)
int minutes(void) const
Get the number of complete minutes in the span.
std::string nanoformat(size_t minwidth=1, size_t maxwidth=9) const
Format the nanosecond fractional part of the time as a string.
TimeSpan & operator%=(const TimeSpan &n)
Compute a modulo of a time span.
Time & operator+=(const TimeSpan &x)
Add the specified amount to the time.
static bool isLeap(int year)
Check if the year is a leap-year.
static Time epoch(void)
Returns the minimum time.
bool operator>=(const Gaudi::Time &t1, const Gaudi::Time &t2)
bool operator!(const Gaudi::Time &t)
int lastHours(void) const
Get the number of complete hours in the last incomplete day of the span.
bool operator<=(const Gaudi::Time &t1, const Gaudi::Time &t2)
Time(void)
Initialize an empty (zero) time value.
TimeSpan(void)
Initialize an empty (zero) time difference.
Time & operator-=(const TimeSpan &x)
Subtract the specified amount from the time.
static Time max(void)
Returns the maximum time.
Helper functions to set/get the application return code.
bool operator<(const Gaudi::Time &t1, const Gaudi::Time &t2)
int hours(void) const
Get the number of complete hours in the span.