#ifndef _utl_UTCDateTime_h_ #define _utl_UTCDateTime_h_ #include #include namespace utl { /** \class UTCDateTime UTCDateTime.h utl/UTCDateTime.h \author Darko Veberic \date 22 Jul 2009 \version $Id$ \ingroup time */ class UTCDateTime : public UTCDate { public: UTCDateTime() : UTCDate(), fHour(0), fMinute(0), fSecond(0), fNanosecond(0) { } UTCDateTime(const UTCDate& date, const int hour = 0, const int minute = 0, const int second = 0, const double nanosecond = 0) : UTCDate(date) { SetHMS(hour, minute, second, nanosecond); } UTCDateTime(const int year, const int month, const int day, const int hour = 0, const int minute = 0, const int second = 0, const double nanosecond = 0) : UTCDate(year, month, day) { SetHMS(hour, minute, second, nanosecond); } UTCDateTime(const TimeStamp& time); void Set(const int year, const int month, const int day, const int hour, const int minute, const int second, const double nanosecond = 0) { UTCDate::Set(year, month, day); SetHMS(hour, minute, second, nanosecond); } std::string GetInAugerFormat() const; std::string GetInXMLFormat() const; std::string GetInMySQLFormat() const; TimeStamp GetTimeStamp() const; int GetHour() const { return fHour; } int GetMinute() const { return fMinute; } int GetSecond() const { return fSecond; } double GetNanosecond() const { return fNanosecond; } /// seconds after Unix epoch (1 Jan 1970) without any leap corrections std::time_t GetUnixSecond() const { return UTCDate::GetUnixSecond(GetYear(), GetMonth(), GetDay(), fHour, fMinute, fSecond); } static UTCDateTime GetUnixEpoch() { return UTCDate::GetUnixEpoch(); } static UTCDateTime GetGPSEpoch() { return UTCDate::GetGPSEpoch(); } static UTCDateTime Max(); static UTCDateTime Min() { return GetGPSEpoch(); } private: void SetHMS(const int hour, const int minute, const int second, const double nanosecond = 0); std::istream& Parse(std::istream& is); int fHour; int fMinute; int fSecond; double fNanosecond; friend std::istream& operator>>(std::istream&, UTCDateTime&); }; inline std::ostream& operator<<(std::ostream& os, const UTCDateTime& utc) { return os << utc.GetInXMLFormat(); } inline std::istream& operator>>(std::istream& is, UTCDateTime& utc) { return utc.Parse(is); } } #endif