+inline bool
+operator!=(const SGTimeStamp& c1, const SGTimeStamp& c2)
+{ return !operator==(c1, c2); }
+
+inline bool
+operator<(const SGTimeStamp& c1, const SGTimeStamp& c2)
+{
+ if (c1.getSeconds() < c2.getSeconds())
+ return true;
+ if (c1.getSeconds() > c2.getSeconds())
+ return false;
+ return c1.getNanoSeconds() < c2.getNanoSeconds();
+}
+
+inline bool
+operator>(const SGTimeStamp& c1, const SGTimeStamp& c2)
+{ return c2 < c1; }
+
+inline bool
+operator>=(const SGTimeStamp& c1, const SGTimeStamp& c2)
+{ return !(c1 < c2); }
+
+inline bool
+operator<=(const SGTimeStamp& c1, const SGTimeStamp& c2)
+{ return !(c1 > c2); }
+
+inline SGTimeStamp
+operator+(const SGTimeStamp& c1)
+{ return c1; }
+
+inline SGTimeStamp
+operator-(const SGTimeStamp& c1)
+{ return SGTimeStamp::fromSec(0) -= c1; }
+
+inline SGTimeStamp
+operator+(const SGTimeStamp& c1, const SGTimeStamp& c2)
+{ return SGTimeStamp(c1) += c2; }
+
+inline SGTimeStamp
+operator-(const SGTimeStamp& c1, const SGTimeStamp& c2)
+{ return SGTimeStamp(c1) -= c2; }
+
+template<typename char_type, typename traits_type>
+inline
+std::basic_ostream<char_type, traits_type>&
+operator<<(std::basic_ostream<char_type, traits_type>& os, const SGTimeStamp& c)
+{
+ std::basic_stringstream<char_type, traits_type> stream;
+
+ SGTimeStamp pos = c;
+ if (c.getSeconds() < 0) {
+ stream << stream.widen('-');
+ pos = - c;
+ }
+ stream << pos.getSeconds() << stream.widen('.');
+ stream << std::setw(9) << std::setfill('0') << pos.getNanoSeconds();
+
+ return os << stream.str();