TimePoint Class Reference

CPP API: mio::abm::TimePoint Class Reference
mio::abm::TimePoint Class Reference

Represents a point in time. More...

#include <time.h>

Public Member Functions

int day_of_week () const
 Index of current day of the week (0,...,6 = Mo,...,Sun). More...
 
ScalarType days () const
 Time since the epoch in days. More...
 
auto default_serialize ()
 This method is used by the default serialization feature. More...
 
int hour_of_day () const
 Hour in the current day (0 - 23). More...
 
ScalarType hours () const
 Time since the epoch in hours. More...
 
bool is_weekend () const
 If the current time is on a weekend, e.g. More...
 
TimeSpan operator- (const TimePoint &p2) const
 TimeSpan difference between this and another TimePoint. More...
 
int seconds () const
 Time since the epoch in seconds. More...
 
TimeSpan time_since_midnight () const
 Time since midnight. More...
 
 TimePoint ()=default
 Default ctor, unitinialized. More...
 
 TimePoint (int seconds)
 Creates a TimePoint from a specified number of seconds. More...
 
Comparison operators.
bool operator== (const TimePoint &other) const
 
bool operator!= (const TimePoint &other) const
 
bool operator< (const TimePoint &other) const
 
bool operator<= (const TimePoint &other) const
 
bool operator> (const TimePoint &other) const
 
bool operator>= (const TimePoint &other) const
 
TimePoint operator+ (const TimeSpan &s) const
 Add or subtract a TimeSpan. More...
 
TimePointoperator+= (const TimeSpan &s)
 Add or subtract a TimeSpan. More...
 
TimePoint operator- (const TimeSpan &s) const
 Add or subtract a TimeSpan. More...
 
TimePointoperator-= (const TimeSpan &s)
 Add or subtract a TimeSpan. More...
 

Private Attributes

int m_seconds
 The number of seconds after the epoch. More...
 

Detailed Description

Represents a point in time.

Seconds from an unspecified monday at 00:00 (epoch).

Constructor & Destructor Documentation

◆ TimePoint() [1/2]

mio::abm::TimePoint::TimePoint ( )
default

Default ctor, unitinialized.

◆ TimePoint() [2/2]

mio::abm::TimePoint::TimePoint ( int  seconds)
inlineexplicit

Creates a TimePoint from a specified number of seconds.

Parameters
[in]secondsThe number of seconds after the epoch.

Member Function Documentation

◆ day_of_week()

int mio::abm::TimePoint::day_of_week ( ) const
inline

Index of current day of the week (0,...,6 = Mo,...,Sun).

◆ days()

ScalarType mio::abm::TimePoint::days ( ) const
inline

Time since the epoch in days.

◆ default_serialize()

auto mio::abm::TimePoint::default_serialize ( )
inline

This method is used by the default serialization feature.

◆ hour_of_day()

int mio::abm::TimePoint::hour_of_day ( ) const
inline

Hour in the current day (0 - 23).

◆ hours()

ScalarType mio::abm::TimePoint::hours ( ) const
inline

Time since the epoch in hours.

◆ is_weekend()

bool mio::abm::TimePoint::is_weekend ( ) const
inline

If the current time is on a weekend, e.g.

day_of_the_week is 5 = Sat or 6 = Sun.

◆ operator!=()

bool mio::abm::TimePoint::operator!= ( const TimePoint other) const
inline

◆ operator+()

TimePoint mio::abm::TimePoint::operator+ ( const TimeSpan s) const
inline

Add or subtract a TimeSpan.

◆ operator+=()

TimePoint& mio::abm::TimePoint::operator+= ( const TimeSpan s)
inline

Add or subtract a TimeSpan.

◆ operator-() [1/2]

TimeSpan mio::abm::TimePoint::operator- ( const TimePoint p2) const
inline

TimeSpan difference between this and another TimePoint.

Parameters
[in]p2The other TimePoint.

◆ operator-() [2/2]

TimePoint mio::abm::TimePoint::operator- ( const TimeSpan s) const
inline

Add or subtract a TimeSpan.

◆ operator-=()

TimePoint& mio::abm::TimePoint::operator-= ( const TimeSpan s)
inline

Add or subtract a TimeSpan.

◆ operator<()

bool mio::abm::TimePoint::operator< ( const TimePoint other) const
inline

◆ operator<=()

bool mio::abm::TimePoint::operator<= ( const TimePoint other) const
inline

◆ operator==()

bool mio::abm::TimePoint::operator== ( const TimePoint other) const
inline

◆ operator>()

bool mio::abm::TimePoint::operator> ( const TimePoint other) const
inline

◆ operator>=()

bool mio::abm::TimePoint::operator>= ( const TimePoint other) const
inline

◆ seconds()

int mio::abm::TimePoint::seconds ( ) const
inline

Time since the epoch in seconds.

◆ time_since_midnight()

TimeSpan mio::abm::TimePoint::time_since_midnight ( ) const
inline

Time since midnight.

Member Data Documentation

◆ m_seconds

int mio::abm::TimePoint::m_seconds
private

The number of seconds after the epoch.