UFO: Alien Invasion
Loading...
Searching...
No Matches
DateTime Class Reference

Class describing a point of time. More...

#include <DateTime.h>

Collaboration diagram for DateTime:
Collaboration graph

Public Member Functions

 DateTime (int day=0, int second=0)
 Construct for DateTime class from date as days and time as seconds.
int getDateAsDays () const
 Return the date part of the DateTime as days.
int getTimeAsSeconds () const
 Return the time part of the DateTime as seconds.
DateTimeoperator+= (const DateTime &other)
 Adds a DateTime (duration) to the left DateTime object.
DateTime operator+ (const DateTime &other) const
 Calcluate the summary of two DateTime objects in a new one.
DateTimeoperator-= (const DateTime &other)
 Substracts a DateTime (duration) from the left DateTime object.
DateTime operator- (const DateTime &other) const
 Calcluate the difference of two DateTime objects in a new one.
bool operator== (const DateTime &other) const
 Decides whether two DateTimes are equal.
bool operator!= (const DateTime &other) const
 Decides whether two DateTimes are different.
bool operator< (const DateTime &other) const
 Decides if the left DateTime is earlier than the right one.
bool operator<= (const DateTime &other) const
 Decides if the left DateTime is earlier or equal to the right one.
bool operator> (const DateTime &other) const
 Decides if the left DateTime is later than the right one.
bool operator>= (const DateTime &other) const
 Decides if the left DateTime is later or equal to the right one.

Static Public Attributes

static const short SECONDS_PER_MINUTE = 60
static const short MINUTES_PER_HOUR = 60
static const short HOURS_PER_DAY = 24
static const int DAYS_PER_YEAR = 365
static constexpr float DAYS_PER_YEAR_AVG = 365.25f
static const short MONTHS_PER_YEAR = 12
static const short SEASONS_PER_YEAR = 4
static const short SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR
static const int SECONDS_PER_DAY = HOURS_PER_DAY * SECONDS_PER_HOUR

Protected Member Functions

void reCalculate (void)
 Handle over- and underflowing date/time parts.

Protected Attributes

int day
int second

Detailed Description

Class describing a point of time.

Definition at line 30 of file DateTime.h.

Constructor & Destructor Documentation

◆ DateTime()

DateTime::DateTime ( int day = 0,
int second = 0 )

Construct for DateTime class from date as days and time as seconds.

Parameters
[in]dayAbsolute number of days
[in]secondAbsolute number of seconds

Definition at line 34 of file DateTime.cpp.

References day, reCalculate(), and second.

Referenced by operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

Member Function Documentation

◆ getDateAsDays()

◆ getTimeAsSeconds()

int DateTime::getTimeAsSeconds ( ) const

◆ operator!=()

bool DateTime::operator!= ( const DateTime & other) const

Decides whether two DateTimes are different.

Definition at line 118 of file DateTime.cpp.

References DateTime().

◆ operator+()

DateTime DateTime::operator+ ( const DateTime & other) const

Calcluate the summary of two DateTime objects in a new one.

Parameters
[in]DateTime&Reference to the date/time duration to add
Returns
A new DateTime object with the result

Definition at line 79 of file DateTime.cpp.

References DateTime().

◆ operator+=()

DateTime & DateTime::operator+= ( const DateTime & other)

Adds a DateTime (duration) to the left DateTime object.

Parameters
[in]DateTime&Reference to the date/time duration to add
Returns
A reference to the modified DateTime object (lvalue)

Definition at line 66 of file DateTime.cpp.

References DateTime(), day, getDateAsDays(), getTimeAsSeconds(), reCalculate(), and second.

◆ operator-()

DateTime DateTime::operator- ( const DateTime & other) const

Calcluate the difference of two DateTime objects in a new one.

Parameters
[in]DateTime&Reference to the date/time duration to substract
Returns
A new DateTime object with the result

Definition at line 102 of file DateTime.cpp.

References DateTime().

◆ operator-=()

DateTime & DateTime::operator-= ( const DateTime & other)

Substracts a DateTime (duration) from the left DateTime object.

Parameters
[in]DateTime&Reference to the date/time duration to substract
Returns
A reference to the modified DateTime object (lvalue)

Definition at line 89 of file DateTime.cpp.

References DateTime(), day, getDateAsDays(), getTimeAsSeconds(), reCalculate(), and second.

◆ operator<()

bool DateTime::operator< ( const DateTime & other) const

Decides if the left DateTime is earlier than the right one.

Definition at line 126 of file DateTime.cpp.

References DateTime(), day, getDateAsDays(), getTimeAsSeconds(), and second.

◆ operator<=()

bool DateTime::operator<= ( const DateTime & other) const

Decides if the left DateTime is earlier or equal to the right one.

Definition at line 134 of file DateTime.cpp.

References DateTime().

◆ operator==()

bool DateTime::operator== ( const DateTime & other) const

Decides whether two DateTimes are equal.

Definition at line 110 of file DateTime.cpp.

References DateTime(), day, getDateAsDays(), getTimeAsSeconds(), and second.

◆ operator>()

bool DateTime::operator> ( const DateTime & other) const

Decides if the left DateTime is later than the right one.

Definition at line 142 of file DateTime.cpp.

References DateTime(), day, getDateAsDays(), getTimeAsSeconds(), and second.

◆ operator>=()

bool DateTime::operator>= ( const DateTime & other) const

Decides if the left DateTime is later or equal to the right one.

Definition at line 150 of file DateTime.cpp.

References DateTime().

◆ reCalculate()

void DateTime::reCalculate ( void )
protected

Handle over- and underflowing date/time parts.

Definition at line 160 of file DateTime.cpp.

References day, int(), second, and SECONDS_PER_DAY.

Referenced by DateTime(), operator+=(), and operator-=().

Field Documentation

◆ day

int DateTime::day
protected

Number of day (starting with 0)

Definition at line 67 of file DateTime.h.

Referenced by DateTime(), getDateAsDays(), operator+=(), operator-=(), operator<(), operator==(), operator>(), and reCalculate().

◆ DAYS_PER_YEAR

const int DateTime::DAYS_PER_YEAR = 365
static

◆ DAYS_PER_YEAR_AVG

float DateTime::DAYS_PER_YEAR_AVG = 365.25f
staticconstexpr

Definition at line 38 of file DateTime.h.

Referenced by GEO_IsNight().

◆ HOURS_PER_DAY

const short DateTime::HOURS_PER_DAY = 24
static

Definition at line 36 of file DateTime.h.

◆ MINUTES_PER_HOUR

const short DateTime::MINUTES_PER_HOUR = 60
static

Definition at line 35 of file DateTime.h.

Referenced by PR_CalculateTotalFrames(), PR_GetProductionHours(), and PR_GetRemainingHours().

◆ MONTHS_PER_YEAR

const short DateTime::MONTHS_PER_YEAR = 12
static

◆ SEASONS_PER_YEAR

const short DateTime::SEASONS_PER_YEAR = 4
static

Definition at line 40 of file DateTime.h.

Referenced by R_Draw3DGlobe().

◆ second

int DateTime::second
protected

Second of the minute

Definition at line 68 of file DateTime.h.

Referenced by DateTime(), getTimeAsSeconds(), operator+=(), operator-=(), operator<(), operator==(), operator>(), and reCalculate().

◆ SECONDS_PER_DAY

◆ SECONDS_PER_HOUR

◆ SECONDS_PER_MINUTE

const short DateTime::SECONDS_PER_MINUTE = 60
static

Definition at line 34 of file DateTime.h.

Referenced by CP_CampaignRun().


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