//////////////////////////////////////////////////////////////////////////////// /*! @file Time.h Время. - Part of RANet - Research Assistant Net Library (based on ANSI C++). - Copyright(C) 2010, Viktor E. Bursian, St.Petersburg, Russia. Viktor.Bursian@mail.ioffe.ru */////////////////////////////////////////////////////////////////////////////// #ifndef Time_H #define Time_H #include "Storable.h" namespace RA { //------------------------------------------------------------------------------ ANNOUNCE_CLASS(sTime) //-------------------------------------------------------------------- sTime --- /*! Absolute date&time with accuracy of 1ms */ class RANet_EXPORT sTime : public virtual sStorable { STORABLE(sTime) public://static static sTime FromMillisecondsSinceEpoch (qint64 ms) { sTime T; T._UTC=ms; return T; } static sTime FromISO_8601 (rcsString); static real ToSeconds (rcsString); public: sTime (); /*!< Creates current time */ sTime (rcsTime); sTime (int year ,int month ,int date ,int hour=0 ,int minute=0 ,int second=0 ,int millisecond=0); rsTime operator = (rcsTime); bool operator == (rcsTime other) const; bool operator < (rcsTime other) const; int Year () const; int Month () const; int Day () const; sString Text () const; sString ToISO_8601 () const { return Text(); } rsTime operator += (real seconds); sTime operator + (real seconds) const; real /*seconds*/ operator - (rcsTime other) const; qint64 ToMillisecondsSinceEpoch () const { return _UTC; } sTime LastMidnight () const; qint64 ToMillisecondsSinceMidnight () const { return _UTC - LastMidnight()._UTC; } private: //fields qint64 _UTC;//!< milliseconds after 1970-01-01 00:00:00 }; /* 2**32 4 294 967 296 60*60*24*1000= 86 400 000 2100*366= 768 600 */ //------------------------------------------------------------------------------ } //namespace RA #endif