40#ifndef WOSS_TIME_DEFINITIONS_H
41#define WOSS_TIME_DEFINITIONS_H
54 #define TIME_NOT_SET_VALUE (LONG_MIN)
86 inline TimeReference::~TimeReference() { }
110 Time(
struct tm* time );
121 Time(
int day,
int month,
int year,
int hours = 0,
int mins = 0,
int seconds = 1 );
235 operator time_t()
const;
379 friend std::ostream& operator<<( std::ostream& os,
const SimTime& instance ) {
380 os <<
"start time = " << instance.start_time <<
"; end time = " << instance.end_time;
399 inline Time::operator time_t()
const {
400 return( mktime(&timeinfo) );
405 if ( &left == &right )
return true;
406 return( mktime(
const_cast<tm*
>(&left.
timeinfo)) == mktime(
const_cast<tm*
>(&right.
timeinfo)) );
411 if ( &left == &right )
return false;
412 return( mktime(
const_cast<tm*
>(&left.
timeinfo)) != mktime(
const_cast<tm*
>(&right.
timeinfo)) );
417 if ( &left == &right )
return false;
418 return( mktime(
const_cast<tm*
>(&left.
timeinfo)) > mktime(
const_cast<tm*
>(&right.
timeinfo)) );
423 if ( &left == &right )
return false;
424 return( mktime(
const_cast<tm*
>(&left.
timeinfo)) < mktime(
const_cast<tm*
>(&right.
timeinfo)) );
429 return( mktime(
const_cast<tm*
>(&left.
timeinfo)) <= mktime(
const_cast<tm*
>(&right.
timeinfo)) );
434 return( mktime(
const_cast<tm*
>(&left.
timeinfo)) >= mktime(
const_cast<tm*
>(&right.
timeinfo)) );
438 inline std::ostream&
operator<<( std::ostream& os,
const Time& time ) {
439 os << asctime(const_cast<tm*>(&time.
timeinfo)) ;
445 time_t sum_time = mktime(
const_cast<tm*
>(&left.
timeinfo)) + right;
446 return(
Time( localtime( &sum_time ) ) );
451 time_t diff_time = mktime(
const_cast<tm*
>(&left.
timeinfo)) - right;
452 return(
Time( localtime( &diff_time ) ) );
bool operator!=(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.h:846
std::ostream & operator<<(std::ostream &os, const Altimetry &instance)
Definition altimetry-definitions.h:826
bool operator==(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.h:840
Altimetry & operator+=(Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:327
const Altimetry operator+(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:257
Altimetry & operator-=(Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:335
const Altimetry operator-(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:264
Class for simulation time reference purposes.
Definition time-definitions.h:63
virtual double getTimeReference() const =0
virtual TimeReference * clone()=0
a class for time date manipulation
Definition time-definitions.h:95
friend bool operator!=(const Time &left, const Time &right)
Definition time-definitions.h:410
struct tm timeinfo
Definition time-definitions.h:352
Time & setMonth(int m)
Definition time-definitions.h:141
time_t raw_time
Definition time-definitions.h:357
friend Time & operator-=(Time &left, time_t right)
Time & setHours(int h)
Definition time-definitions.h:163
int getMinutes() const
Definition time-definitions.h:222
int getHours() const
Definition time-definitions.h:210
Time & setDay(int d)
Definition time-definitions.h:149
Time()
Definition time-definitions.cpp:52
Time & operator=(const Time ©)
Definition time-definitions.cpp:108
friend::std::ostream & operator<<(::std::ostream &os, const Time &instance)
int getSeconds() const
Definition time-definitions.h:228
~Time()
Definition time-definitions.h:133
Time & setMinutes(int m)
Definition time-definitions.h:170
friend const Time operator+(const Time &left, const time_t right)
Definition time-definitions.h:444
int getDay() const
Definition time-definitions.h:204
friend bool operator==(const Time &left, const Time &right)
Definition time-definitions.h:404
static bool debug
Definition time-definitions.h:363
Time & setYear(int y)
Definition time-definitions.h:156
int getYear() const
Definition time-definitions.h:216
static void setDebug(bool flag)
Definition time-definitions.h:184
friend bool operator<(const Time &left, const Time &right)
Definition time-definitions.h:422
Time & setSeconds(int s)
Definition time-definitions.h:177
int getMonth() const
Definition time-definitions.h:198
friend Time & operator+=(Time &left, time_t right)
bool isValid() const
Definition time-definitions.h:191
friend const Time operator-(const Time &left, const time_t right)
Definition time-definitions.h:450
friend double operator-(const Time &left, const Time &right)
friend bool operator>=(const Time &left, const Time &right)
Definition time-definitions.h:433
friend bool operator<=(const Time &left, const Time &right)
Definition time-definitions.h:428
friend bool operator>(const Time &left, const Time &right)
Definition time-definitions.h:416
bool operator<=(const Coord &left, const Coord &right)
Definition coordinates-definitions.h:928
bool operator>=(const Coord &left, const Coord &right)
Definition coordinates-definitions.h:922
bool operator<(const Coord &left, const Coord &right)
Definition coordinates-definitions.h:916
bool operator>(const Coord &left, const Coord &right)
Definition coordinates-definitions.h:910
Struct that stores start and end Time.
Definition time-definitions.h:373