DateTime.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008 Jakub Filak <xfilak01@stud.fit.vutbr.cz>
00003  *
00004  * This file is part of rob08
00005  *
00006  * rob08 is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, either version 3 of the License, or
00009  * any later version.
00010  *
00011  * rob08 is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with rob08.  If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #ifndef __DATE_TIME_H__
00021 #define __DATE_TIME_H__
00022 
00023 #include <time.h>
00024 #include <limits.h>
00025 #include <sys/time.h>
00026 #include <iostream>
00027 #include <string>
00028 
00029 #define DIG_COUNT 1e6
00030 
00031 typedef double StampType;
00032 
00033 class DateTime
00034 {
00035   public:
00036     DateTime( time_t seconds = 0, suseconds_t micros = 0 );
00037     DateTime( const DateTime& right );
00038     DateTime( const StampType& right );
00039 
00040     StampType Stamp() const;
00041     unsigned Seconds() const;
00042     unsigned MicroSeconds() const;
00043     
00044     DateTime& operator=( const DateTime& );
00045     DateTime& operator=( const StampType& );
00046 
00047     static DateTime Now();
00048     static DateTime MinValue();
00049     static DateTime MaxValue();
00050 
00051     static StampType RoundStamp( const StampType& stmp );
00052 
00053     friend std::ostream& operator<<( std::ostream& output, const DateTime& date );
00054     friend std::istream& operator>>( std::istream& input, DateTime& date );
00055 
00056   private:
00057     time_t m_seconds;
00058     suseconds_t m_ms;
00059 };
00060 
00061 bool operator==( const DateTime& lhs, const DateTime& rhs );
00062 bool operator!=( const DateTime& lhs, const DateTime& rhs );
00063 bool operator<( const DateTime& lhs, const DateTime& rhs ); 
00064 bool operator>( const DateTime& lhs, const DateTime& rhs );
00065 bool operator<=( const DateTime& lhs, const DateTime& rhs );
00066 bool operator>=( const DateTime& lhs, const DateTime& rhs );
00067 StampType operator-( const DateTime& lhs, const DateTime& rhs );
00068 DateTime operator+( const DateTime& lhs, const StampType& rhs );
00069 
00070 #endif
00071 

Generated on Fri Jul 10 22:42:01 2009 for rob08 by  doxygen 1.5.4