15 #include "../../include/ecl/time/timestamp_base.hpp" 29 time.tv_sec =
static_cast<long>(decimal_time_value);
30 time.tv_nsec = (decimal_time_value -
static_cast<long>(decimal_time_value))*1000000000L;
35 ( (seconds < 0) && (nanoseconds <= 0) ) ||
38 time.tv_sec = seconds;
39 time.tv_nsec = nanoseconds;
47 time.tv_sec =
static_cast<time_t
>(decimal_time_value);
48 time.tv_nsec = (decimal_time_value -
static_cast<long>(decimal_time_value))*1000000000L;
54 ( (seconds < 0) && (nanoseconds <= 0) ) ||
57 time.tv_sec = seconds;
58 time.tv_nsec = nanoseconds;
67 if( ( time_stamp.
time.tv_sec ==
time.tv_sec ) && ( time_stamp.
time.tv_nsec ==
time.tv_nsec ) ) {
75 if( ( time_stamp.
time.tv_sec ==
time.tv_sec ) && ( time_stamp.
time.tv_nsec ==
time.tv_nsec ) ) {
83 if(
time.tv_sec > time_stamp.
time.tv_sec ) {
85 }
else if (
time.tv_sec == time_stamp.
time.tv_sec ) {
86 if (
time.tv_nsec > time_stamp.
time.tv_nsec ) {
94 if(
time.tv_sec < time_stamp.
time.tv_sec ) {
96 }
else if (
time.tv_sec == time_stamp.
time.tv_sec ) {
97 if (
time.tv_nsec < time_stamp.
time.tv_nsec ) {
105 if(
time.tv_sec > time_stamp.
time.tv_sec ) {
107 }
else if (
time.tv_sec == time_stamp.
time.tv_sec ) {
108 if (
time.tv_nsec >= time_stamp.
time.tv_nsec ) {
116 if(
time.tv_sec < time_stamp.
time.tv_sec ) {
118 }
else if (
time.tv_sec == time_stamp.
time.tv_sec ) {
119 if (
time.tv_nsec <= time_stamp.
time.tv_nsec ) {
130 time.tv_sec += time_stamp.
time.tv_sec;
132 if ( nsec >= 1000000000L ) {
135 }
else if ( nsec <= -1000000000L ) {
139 if ( (
time.tv_sec > 0 ) && ( nsec < 0 ) ) {
141 nsec = 1000000000L +
nsec;
143 if ( (
time.tv_sec < 0 ) && ( nsec > 0 ) ) {
145 nsec = nsec - 1000000000L;
153 if ( nsec >= 1000000000L ) {
156 }
else if ( nsec <= -1000000000L ) {
160 if ( ( sec > 0 ) && ( nsec < 0 ) ) {
162 nsec = 1000000000L +
nsec;
164 if ( ( sec < 0 ) && ( nsec > 0 ) ) {
166 nsec = nsec - 1000000000L;
172 time_t
sec =
time.tv_sec - time_stamp.time.tv_sec;
173 long nsec =
time.tv_nsec - time_stamp.time.tv_nsec;
175 if ( (sec > 0) && ( nsec < 0 )) {
178 }
else if ( (sec < 0) && ( nsec > 0 )) {
187 time_t
sec =
time.tv_sec - time_stamp.time.tv_sec;
188 long nsec =
time.tv_nsec - time_stamp.time.tv_nsec;
190 if ( (sec > 0) && ( nsec < 0 )) {
193 }
else if ( (sec < 0) && ( nsec > 0 )) {
Embedded control libraries.
bool operator>(const TimeStampBase &time_stamp)
bool operator==(const TimeStampBase &time_stamp)
bool operator<=(const TimeStampBase &time_stamp)
TimeStampBase operator+(const TimeStampBase &time_stamp)
This class provides common functionality across platforms for the timestamps.
long sec() const
Seconds component.
long nsec() const
Nanoseconds component (after removing seconds).
#define ecl_assert_throw(expression, exception)
bool operator>=(const TimeStampBase &time_stamp)
const TimeStampBase & stamp(const double &decimal_time_value) ecl_assert_throw_decl(StandardException)
Manually set the timestamp.
bool operator<(const TimeStampBase &time_stamp)
void operator+=(const TimeStampBase &time_stamp)
bool operator!=(const TimeStampBase &time_stamp)
void operator-=(const TimeStampBase &time_stamp) ecl_assert_throw_decl(StandardException)
#define ecl_assert_throw_decl(exception)
TimeStampBase operator-(const TimeStampBase &time_stamp) ecl_assert_throw_decl(StandardException)