@TimeStamp.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /******************************************************************************/
  2. /******************************************************************************/
  3. class TimeStamp
  4. {
  5. static const long Start, // 63524217600 is the number of seconds at 1st Jan 2013 (approximate time of the first application version)
  6. Unix ; // 62167219200 is the number of seconds at 1st Jan 1970
  7. uint u;
  8. bool is()C; // if was set
  9. uint text()C; // this method is used when saving to text, it can be replaced in the future to something like "Str text()C {return ..;}"
  10. TimeStamp& operator--( );
  11. TimeStamp& operator--(int);
  12. TimeStamp& operator++( );
  13. TimeStamp& operator++(int);
  14. TimeStamp& zero ();
  15. TimeStamp& getUTC(); // set to current time
  16. TimeStamp& now (); // set to current time and make sure that it's newer than the previous time
  17. TimeStamp& fromUnix(long u);
  18. bool old(C TimeStamp &now=TimeStamp().getUTC())C; // if this timestamp is older than 'now'
  19. bool operator==(C TimeStamp &t)C; // if equal
  20. bool operator!=(C TimeStamp &t)C; // if not equal
  21. bool operator>=(C TimeStamp &t)C; // if greater or equal
  22. bool operator<=(C TimeStamp &t)C; // if smaller or equal
  23. bool operator> (C TimeStamp &t)C; // if greater
  24. bool operator< (C TimeStamp &t)C; // if smaller
  25. TimeStamp& operator+=(int i);
  26. TimeStamp& operator-=(int i);
  27. TimeStamp operator+(int i);
  28. TimeStamp operator-(int i);
  29. long operator-(C TimeStamp &t)C;
  30. DateTime asDateTime()C;
  31. TimeStamp( int i );
  32. TimeStamp( uint u );
  33. TimeStamp( long l );
  34. TimeStamp(C DateTime &dt);
  35. TimeStamp(C Str &t ); // this method is used when loading from text, it can be replaced in the future
  36. static int Compare(C TimeStamp &a, C TimeStamp &b);
  37. public:
  38. TimeStamp();
  39. };
  40. /******************************************************************************/
  41. /******************************************************************************/
  42. extern TimeStamp CurTime;
  43. /******************************************************************************/