World Ocean Simulation System (WOSS) library
woss::Time Class Reference

a class for time date manipulation More...

#include <time-definitions.h>

Collaboration diagram for woss::Time:
Collaboration graph

Public Member Functions

 Time ()
 Time (struct tm *time)
 Time (int day, int month, int year, int hours=0, int mins=0, int seconds=1)
 Time (const Time &copy)=default
 Time (Time &&tmp)=default
 ~Time ()=default
TimesetMonth (int m)
TimesetDay (int d)
TimesetYear (int y)
TimesetHours (int h)
TimesetMinutes (int m)
TimesetSeconds (int s)
bool isValid () const
int getMonth () const
int getDay () const
int getHours () const
int getYear () const
int getMinutes () const
int getSeconds () const
 operator time_t () const
Timeoperator= (const Time &copy)=default
Timeoperator= (Time &&tmp)=default

Static Public Member Functions

static void setDebug (bool flag)

Protected Attributes

struct tm timeinfo
time_t raw_time

Static Protected Attributes

static bool debug = false

Friends

const Time operator+ (const Time &left, const time_t right)
const Time operator- (const Time &left, const time_t right)
double operator- (const Time &left, const Time &right)
Timeoperator+= (Time &left, time_t right)
Timeoperator-= (Time &left, time_t right)
bool operator== (const Time &left, const Time &right)
bool operator!= (const Time &left, const Time &right)
bool operator> (const Time &left, const Time &right)
bool operator< (const Time &left, const Time &right)
bool operator<= (const Time &left, const Time &right)
bool operator>= (const Time &left, const Time &right)
std::ostream & operator<< (std::ostream &os, const Time &instance)

Detailed Description

a class for time date manipulation

Time class offers the possibility to store and manipulate date time. A time date consists of a day, month, year, hours, minutes and seconds.

Constructor & Destructor Documentation

◆ Time() [1/5]

◆ Time() [2/5]

Time::Time ( struct tm * time)

Time constructor

Parameters
timestruct tm from ctime library

References raw_time, and timeinfo.

◆ Time() [3/5]

Time::Time ( int day,
int month,
int year,
int hours = 0,
int mins = 0,
int seconds = 1 )

Time constructor

Parameters
dayday value. Should be between 1 and 31
monthmonth value. Should be between 1 and 12
yearyear value.
hourshours value. Should be between 0 and 23
minsminutes value. Should be between 0 and 59
secondsseconds value. Should be between 0 and 59

References raw_time, and timeinfo.

◆ Time() [4/5]

woss::Time::Time ( const Time & copy)
default

References Time().

Here is the call graph for this function:

◆ Time() [5/5]

woss::Time::Time ( Time && tmp)
default

References Time().

Here is the call graph for this function:

◆ ~Time()

woss::Time::~Time ( )
default

Member Function Documentation

◆ getDay()

int woss::Time::getDay ( ) const
inline

Returns day value

Returns
day value between 1 and 31

References timeinfo.

Referenced by WossUnitTest::testTime().

◆ getHours()

int woss::Time::getHours ( ) const
inline

Returns hours value

Returns
hours value between 0 and 23

References timeinfo.

Referenced by WossUnitTest::testTime().

◆ getMinutes()

int woss::Time::getMinutes ( ) const
inline

Returns minutes value

Returns
minutes value between 0 and 59

References timeinfo.

◆ getMonth()

int woss::Time::getMonth ( ) const
inline

Returns month value

Returns
month value between 1 and 12

References timeinfo.

Referenced by WossUnitTest::testTime().

◆ getSeconds()

int woss::Time::getSeconds ( ) const
inline

Returns seconds value

Returns
seconds value between 0 and 59

References timeinfo.

◆ getYear()

int woss::Time::getYear ( ) const
inline

Returns year value

Returns
year value

References timeinfo.

Referenced by WossUnitTest::testTime().

◆ isValid()

◆ operator time_t()

woss::Time::operator time_t ( ) const
inline

time_t operator

Returns
the time_t

References timeinfo.

◆ operator=() [1/2]

Time & woss::Time::operator= ( const Time & copy)
default

References Time().

Here is the call graph for this function:

◆ operator=() [2/2]

Time & woss::Time::operator= ( Time && tmp)
default

References Time().

Here is the call graph for this function:

◆ setDay()

Time & woss::Time::setDay ( int d)
inline

Sets day

Parameters
dday value. Should be between 1 and 31
Returns
reference to *this

References raw_time, Time(), and timeinfo.

Referenced by WossUnitTest::testTime().

Here is the call graph for this function:

◆ setDebug()

void woss::Time::setDebug ( bool flag)
inlinestatic

Sets debug flag for all instances

Parameters
flagdebug bool

References debug.

◆ setHours()

Time & woss::Time::setHours ( int h)
inline

Sets hours

Parameters
mhours value. Should be between 0 and 23
Returns
reference to *this

References raw_time, Time(), and timeinfo.

Here is the call graph for this function:

◆ setMinutes()

Time & woss::Time::setMinutes ( int m)
inline

Sets minutes

Parameters
mminutes value. Should be between 0 and 59
Returns
reference to *this

References raw_time, Time(), and timeinfo.

Here is the call graph for this function:

◆ setMonth()

Time & woss::Time::setMonth ( int m)
inline

Sets month

Parameters
mmonth value. Should be between 1 and 12
Returns
reference to *this

References raw_time, Time(), and timeinfo.

Referenced by WossUnitTest::testTime().

Here is the call graph for this function:

◆ setSeconds()

Time & woss::Time::setSeconds ( int s)
inline

Sets seconds

Parameters
sseconds value. Should be between 0 and 59
Returns
reference to *this

References raw_time, Time(), and timeinfo.

Here is the call graph for this function:

◆ setYear()

Time & woss::Time::setYear ( int y)
inline

Sets year

Parameters
yyear value
Returns
reference to *this

References raw_time, Time(), and timeinfo.

Referenced by WossUnitTest::testTime().

Here is the call graph for this function:

◆ operator!=

bool operator!= ( const Time & left,
const Time & right )
friend

Inequality operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left != right, false otherwise

References Time(), and timeinfo.

◆ operator+

const Time operator+ ( const Time & left,
const time_t right )
friend

Sum operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
a new const instance holding the operation result

References Time(), and timeinfo.

◆ operator+=

Time & operator+= ( Time & left,
time_t right )
friend

Compound assignment sum operator

Parameters
leftleft operand reference
rightright operand const time_t representing seconds
Returns
left reference after the operation

References Time().

◆ operator- [1/2]

double operator- ( const Time & left,
const Time & right )
friend

Subtraction operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
time difference in seconds

References Time().

◆ operator- [2/2]

const Time operator- ( const Time & left,
const time_t right )
friend

Subtraction operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
a new const instance holding the operation result

References Time(), and timeinfo.

◆ operator-=

Time & operator-= ( Time & left,
time_t right )
friend

Compound assignment subtraction operator

Parameters
leftleft operand reference
rightright operand const time_t representing seconds
Returns
left reference after the operation

References Time().

◆ operator<

bool operator< ( const Time & left,
const Time & right )
friend

Less than operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left < right, false otherwise

References Time(), and timeinfo.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Time & instance )
friend

<< operator

Parameters
osleft operand ostream reference
instanceright operand const Time reference
Returns
os reference after the operation

References Time(), and timeinfo.

◆ operator<=

bool operator<= ( const Time & left,
const Time & right )
friend

Less than or equal to operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left <= right, false otherwise

References Time(), and timeinfo.

◆ operator==

bool operator== ( const Time & left,
const Time & right )
friend

Equality operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left == right, false otherwise

References Time(), and timeinfo.

◆ operator>

bool operator> ( const Time & left,
const Time & right )
friend

Greater than operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left > right, false otherwise

References Time(), and timeinfo.

◆ operator>=

bool operator>= ( const Time & left,
const Time & right )
friend

Greater than or equal to operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left >= right, false otherwise

References Time(), and timeinfo.

Member Data Documentation

◆ debug

bool Time::debug = false
staticprotected

Debug flag

Referenced by setDebug().

◆ raw_time

time_t woss::Time::raw_time
protected

Number of seconds corresponding to date time timeinfo

Referenced by isValid(), woss::operator+=(), woss::operator-=(), setDay(), setHours(), setMinutes(), setMonth(), setSeconds(), setYear(), Time(), Time(), and Time().

◆ timeinfo


The documentation for this class was generated from the following files: