14 #ifndef LLVM_SUPPORT_TIMEVALUE_H
15 #define LLVM_SUPPORT_TIMEVALUE_H
17 #include "llvm/Support/DataTypes.h"
92 : seconds_( seconds ), nanos_( nanos ) { this->normalize(); }
98 : seconds_( 0 ) , nanos_ ( 0 ) {
100 seconds_ = integer_part;
119 this->seconds_ += that.seconds_ ;
120 this->nanos_ += that.nanos_ ;
129 this->seconds_ -= that.seconds_ ;
130 this->nanos_ -= that.nanos_ ;
144 if ( this->seconds_ > that.seconds_ ) {
146 }
else if ( this->seconds_ == that.seconds_ ) {
147 if ( this->nanos_ > that.nanos_ )
return 1;
160 if ( this->seconds_ > that.seconds_ ) {
162 }
else if ( this->seconds_ == that.seconds_ ) {
163 if ( this->nanos_ >= that.nanos_ )
return 1;
171 return (this->seconds_ == that.seconds_) &&
172 (this->nanos_ == that.nanos_);
243 uint64_t result = seconds_ - PosixZeroTimeSeconds;
251 return seconds_ - PosixZeroTimeSeconds;
259 uint64_t result = (uint64_t)10000000 * (seconds_ - Win32ZeroTimeSeconds);
268 seconds = seconds_ - PosixZeroTimeSeconds;
275 std::string
str()
const;
286 this->seconds_ = sec;
297 this->nanos_ = nanos;
335 seconds_ = seconds + PosixZeroTimeSeconds;
344 this->seconds_ = win32Time / 10000000 + Win32ZeroTimeSeconds;
372 TimeValue sum (tv1.seconds_ + tv2.seconds_, tv1.nanos_ + tv2.nanos_);
378 TimeValue difference (tv1.seconds_ - tv2.seconds_, tv1.nanos_ - tv2.nanos_ );
379 difference.normalize ();
std::string str() const
Convert time to a string.
TimeValue()
Default construct a time value, initializing to ZeroTime.
static TimeValue now()
Creates a TimeValue with the current time (UTC).
TimeValue(SecondsType seconds, NanoSecondsType nanos=0)
Explicit constructor.
void microseconds(int32_t micros)
Set the nanoseconds component using a number of microseconds.
static const TimeValue ZeroTime
00:00:00 Jan 1, 2000 UTC.
void seconds(SecondsType sec)
Set the seconds component.
int32_t NanoSecondsType
Type used for representing nanoseconds.
TimeValue operator-(const TimeValue &tv1, const TimeValue &tv2)
Posix tick is 100 Hz (10ms)
static const TimeValue MinTime
The smallest possible time value.
SecondsType seconds() const
Retrieve the seconds component.
uint64_t usec() const
Convert to a number of microseconds (can overflow)
NanoSecondsType nanoseconds() const
Retrieve the nanoseconds component.
void msec(int64_t milliseconds)
Converts from millisecond format to TimeValue format.
void milliseconds(int32_t millis)
Set the nanoseconds component using a number of milliseconds.
int operator<=(const TimeValue &that) const
True if this <= that.
TimeValue(double new_time)
Double Constructor.
static const TimeValue MaxTime
The largest possible time value.
TimeValue & operator+=(const TimeValue &that)
Incrementing assignment operator.
uint64_t toEpochTime() const
int operator<(const TimeValue &that) const
True if this < that.
uint64_t msec() const
Convert to a number of milliseconds (can overflow)
void fromWin32Time(uint64_t win32Time)
Convert seconds form Windows FILETIME to TimeValue.
int operator==(const TimeValue &that) const
int operator!=(const TimeValue &that) const
TimeValue operator+(const TimeValue &tv1, const TimeValue &tv2)
int64_t SecondsType
Type used for representing seconds.
int operator>=(const TimeValue &that) const
static const TimeValue Win32ZeroTime
00:00:00 Jan 1, 1601 UTC.
static const TimeValue PosixZeroTime
00:00:00 Jan 1, 1970 UTC.
uint32_t milliseconds() const
Retrieve the fractional part as milliseconds;.
uint64_t toPosixTime() const
Convert to unix time (100 nanoseconds since 12:00:00a Jan 1,1970)
void fromEpochTime(SecondsType seconds)
Convert seconds form PosixTime to TimeValue.
void usec(int64_t microseconds)
Converts from microsecond format to TimeValue format.
int operator>(const TimeValue &that) const
True if this > that.
friend TimeValue operator+(const TimeValue &tv1, const TimeValue &tv2)
Addition operator.
Win32 tick is 100 Hz (10ms)
void getTimespecTime(uint64_t &seconds, uint32_t &nanos) const
Convert to timespec time (ala POSIX.1b)
Provides an abstraction for a fixed point in time.
uint32_t microseconds() const
Retrieve the fractional part as microseconds;.
friend TimeValue operator-(const TimeValue &tv1, const TimeValue &tv2)
Subtraction operator.
TimeValue & operator-=(const TimeValue &that)
Decrementing assignment operator.
uint64_t toWin32Time() const
Convert to Win32's FILETIME (100ns intervals since 00:00:00 Jan 1, 1601 UTC)
void nanoseconds(NanoSecondsType nanos)
Set the nanoseconds component using a number of nanoseconds.