TriloBot Simulator (C++, Qt4, Flex, Readline, Boost)
File detail
Source code
/*
* Copyright (C) 2008 Jakub Filak <xfilak01@stud.fit.vutbr.cz>
*
* This file is part of rob08
*
* rob08 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* rob08 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rob08. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __DATE_TIME_H__
#define __DATE_TIME_H__
#include <time.h>
#include <limits.h>
#include <sys/time.h>
#include <iostream>
#include <string>
#define DIG_COUNT 1e6
typedef double StampType;
class DateTime
{
public:
DateTime( time_t seconds = 0, suseconds_t micros = 0 );
DateTime( const DateTime& right );
DateTime( const StampType& right );
StampType Stamp() const;
unsigned Seconds() const;
unsigned MicroSeconds() const;
DateTime& operator=( const DateTime& );
DateTime& operator=( const StampType& );
static DateTime Now();
static DateTime MinValue();
static DateTime MaxValue();
static StampType RoundStamp( const StampType& stmp );
friend std::ostream& operator<<( std::ostream& output, const DateTime& date );
friend std::istream& operator>>( std::istream& input, DateTime& date );
private:
time_t m_seconds;
suseconds_t m_ms;
};
bool operator==( const DateTime& lhs, const DateTime& rhs );
bool operator!=( const DateTime& lhs, const DateTime& rhs );
bool operator<( const DateTime& lhs, const DateTime& rhs );
bool operator>( const DateTime& lhs, const DateTime& rhs );
bool operator<=( const DateTime& lhs, const DateTime& rhs );
bool operator>=( const DateTime& lhs, const DateTime& rhs );
StampType operator-( const DateTime& lhs, const DateTime& rhs );
DateTime operator+( const DateTime& lhs, const StampType& rhs );
#endif