OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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

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

Definition at line 95 of file C4TimeMilliseconds.cpp.

References C4TimeMilliseconds::NoInfinity.

96 {
97  // if infinity is set, nothing else than infinity matters (infinity + 100 == infinity)
98  if (lhs.inf != C4TimeMilliseconds::NoInfinity ||
100  {
101  int infinityTo = lhs.inf - rhs.inf;
102 
103  if (infinityTo < 0) return std::numeric_limits<int32_t>::min();
104  if (infinityTo > 0) return std::numeric_limits<int32_t>::max();
105  return 0;
106  }
107  // otherwise, as usual
108  return int32_t(lhs.time - rhs.time);
109 }
bool operator< ( const C4TimeMilliseconds lhs,
const C4TimeMilliseconds rhs 
)

Definition at line 85 of file C4TimeMilliseconds.cpp.

References C4TimeMilliseconds::NoInfinity.

86 {
87  if (lhs.inf != C4TimeMilliseconds::NoInfinity ||
89  {
90  return lhs.inf < rhs.inf;
91  }
92  return int32_t(lhs.time - rhs.time) < 0;
93 }
bool operator== ( const C4TimeMilliseconds lhs,
const C4TimeMilliseconds rhs 
)

Definition at line 79 of file C4TimeMilliseconds.cpp.

80 {
81  return lhs.inf == rhs.inf &&
82  lhs.time == rhs.time;
83 }