/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/facilities/facilities-00-00-04/facilities/Timestamp.h

Go to the documentation of this file.
00001 // $Header: /bes/bes/BossCvs/Calibration/facilities/facilities/Timestamp.h,v 1.1.1.1 2005/10/17 06:11:40 maqm Exp $
00002 #ifndef FACILITIES_TIMESTAMP_H
00003 #define FACILITIES_TIMESTAMP_H
00004 
00005 #include <string>
00006 
00007 namespace facilities {
00008 
00013   class BadTimeInput {
00014   public:
00015     BadTimeInput(std::string msg) : complaint(msg) {};
00016     ~BadTimeInput() {};
00017     std::string complaint; 
00018 
00019     BadTimeInput(const BadTimeInput &other) {complaint = other.complaint; };
00020   }; 
00021 
00022 
00049   class Timestamp {
00050   public:
00053     Timestamp();
00054 
00058     Timestamp(long int seconds, int nano = 0, int tzOffset = 0);
00059 
00061     Timestamp(double julian);
00062 
00063 
00074     Timestamp(const std::string& str, int tzOffset = 0);
00075 
00077     Timestamp(int year, int month, int day, 
00078               int hour = 0, int minute = 0, 
00079               int second = 0, int nano = 0);
00080 
00082     std::string getString() const;
00083 
00085     double      getJulian() const;
00086 
00087     double      getNano() const {return m_nano;}
00088     long int    getClibTime() const {return m_time;}
00089 
00090     bool operator<(const Timestamp& other) const {
00091       return ((m_time < other.m_time) || 
00092               ((m_time == other.m_time) && (m_nano < other.m_nano)));
00093     }
00094 
00095     bool operator>(const Timestamp& other) const {
00096       return (other < (*this));
00097         
00098     }
00099 
00100     bool operator<=(const Timestamp& other) const {
00101       return ( !(other < (*this)) );
00102     }
00103 
00104     bool operator>=(const Timestamp& other) const {
00105       return ( !( (*this) < other ) );
00106     }
00107 
00108 
00109     Timestamp& operator= (const Timestamp& other) {
00110       m_time = other.m_time; m_nano = other.m_nano; 
00111       return *this;
00112     }
00113 
00114     bool operator==(const Timestamp& other) const{
00115       return ((m_time == other.m_time) && (m_nano == other.m_nano));
00116     }
00117 
00118     bool operator!=(const Timestamp& other) const {
00119       return (!(*this == other));
00120     }
00121 
00122     //             << (for debugging)
00123   private:
00124     // See the U.S. Naval Observatory site, 
00125     //   http://aa.usno.navy.mil/data/docs/JulianDate.html,
00126     // used to compute Julian date for Jan 1, 1970
00127     static const double julian1970;
00128     static const int    secPerDay;
00129     static const double  inverseNano;
00130     static const int     inverseNanoInt;
00131     static const long int maxInt;
00132 
00137     class TZOffset {
00138     public:
00139       TZOffset();          
00140       long int m_tzseconds;     // 0 for GMT, 28800 for PDT, etc.
00141       int      m_isDst;   // Not yet sure if we need it
00142     };
00143     static  TZOffset s_tz;
00144 
00146     static time_t toBinary(const std::string& strTime); 
00147 
00149     static void toString(time_t bin, std::string& strTime);
00150 
00151   protected:
00153     time_t m_time;
00154 
00156     int  m_nano;
00157   };
00158 
00159 }
00160 
00161 #endif

Generated on Tue Nov 29 22:57:55 2016 for BOSS_7.0.2 by  doxygen 1.4.7