OpenClonk
C4TimeMilliseconds.cpp File Reference
#include "C4Include.h"
#include "platform/C4TimeMilliseconds.h"
#include <limits>
#include <time.h>
Include dependency graph for C4TimeMilliseconds.cpp:

Go to the source code of this file.

Functions

bool operator== (const C4TimeMilliseconds &lhs, const C4TimeMilliseconds &rhs)
 
bool operator< (const C4TimeMilliseconds &lhs, const C4TimeMilliseconds &rhs)
 
int32_t operator- (const C4TimeMilliseconds &lhs, const C4TimeMilliseconds &rhs)
 

Function Documentation

◆ operator-()

int32_t operator- ( const C4TimeMilliseconds lhs,
const C4TimeMilliseconds rhs 
)

Definition at line 90 of file C4TimeMilliseconds.cpp.

91 {
92  // if infinity is set, nothing else than infinity matters (infinity + 100 == infinity)
93  if (lhs.inf != C4TimeMilliseconds::NoInfinity ||
95  {
96  int infinityTo = lhs.inf - rhs.inf;
97 
98  if (infinityTo < 0) return std::numeric_limits<int32_t>::min();
99  if (infinityTo > 0) return std::numeric_limits<int32_t>::max();
100  return 0;
101  }
102  // otherwise, as usual
103  return int32_t(lhs.time - rhs.time);
104 }

◆ operator<()

bool operator< ( const C4TimeMilliseconds lhs,
const C4TimeMilliseconds rhs 
)

Definition at line 80 of file C4TimeMilliseconds.cpp.

81 {
82  if (lhs.inf != C4TimeMilliseconds::NoInfinity ||
84  {
85  return lhs.inf < rhs.inf;
86  }
87  return lhs.time < rhs.time;
88 }

◆ operator==()

bool operator== ( const C4TimeMilliseconds lhs,
const C4TimeMilliseconds rhs 
)

Definition at line 74 of file C4TimeMilliseconds.cpp.

75 {
76  return lhs.inf == rhs.inf &&
77  lhs.time == rhs.time;
78 }