Kanzi  3.9.7
Kanzi Engine API
kanzi::TimeInterval Struct Reference

Interval in time specified as start and end timestamps. More...

#include <kanzi/core/time/time_interval.hpp>

Public Member Functions

chrono::milliseconds clampToInterval (chrono::milliseconds time) const
 Clamps time to interval. More...
 
bool contains (chrono::milliseconds time) const
 Determines whether the interval contains specified timestamp. More...
 
optional< chrono::milliseconds > getDuration () const
 Gets the duration of interval. More...
 
optional< chrono::milliseconds > getEnd () const
 Gets end timestamp. More...
 
optional< chrono::milliseconds > getStart () const
 Gets start timestamp. More...
 
bool isEnd (chrono::milliseconds time) const
 Determines whether specified timestamp equals to end of interval. More...
 
bool isStart (chrono::milliseconds time) const
 Determines whether specified timestamp equals to start of interval. More...
 
 TimeInterval ()
 Default constructor. More...
 
 TimeInterval (optional< chrono::milliseconds > start, optional< chrono::milliseconds > end)
 Constructor. More...
 

Static Public Member Functions

static TimeInterval createFromStartTimeAndDuration (chrono::milliseconds start, optional< chrono::milliseconds > duration)
 Creates interval from start time and duration. More...
 

Detailed Description

Interval in time specified as start and end timestamps.

Constructor & Destructor Documentation

kanzi::TimeInterval::TimeInterval ( )
explicit

Default constructor.

Initializes start of interval to negative infinity and end of interval to negative infinity.

kanzi::TimeInterval::TimeInterval ( optional< chrono::milliseconds >  start,
optional< chrono::milliseconds >  end 
)
explicit

Constructor.

If start and end are both defined and start in bigger than end, interval will switch start and end.

Parameters
startStart timestamp of interval. Empty optional specifies negative infinity.
endEnd timestamp of interval. Empty optional specifies positive infinity.

Member Function Documentation

optional<chrono::milliseconds> kanzi::TimeInterval::getStart ( ) const

Gets start timestamp.

Empty optional specifies negative infinity.

Returns
start timestamp.
optional<chrono::milliseconds> kanzi::TimeInterval::getEnd ( ) const

Gets end timestamp.

Empty optional specifies positive infinity.

Returns
end timestamp.
optional<chrono::milliseconds> kanzi::TimeInterval::getDuration ( ) const

Gets the duration of interval.

Empty optional specifies infinite duration.

Returns
end timestamp.
bool kanzi::TimeInterval::contains ( chrono::milliseconds  time) const

Determines whether the interval contains specified timestamp.

Parameters
timeTimestamp to test.
Returns
true if the timestamp is within interval, false otherwise.
bool kanzi::TimeInterval::isStart ( chrono::milliseconds  time) const

Determines whether specified timestamp equals to start of interval.

Parameters
timeTimestamp to test.
Returns
true if the timestamp equals to start of interval.
bool kanzi::TimeInterval::isEnd ( chrono::milliseconds  time) const

Determines whether specified timestamp equals to end of interval.

Parameters
timeTimestamp to test.
Returns
true if the timestamp equals to end of interval.
chrono::milliseconds kanzi::TimeInterval::clampToInterval ( chrono::milliseconds  time) const

Clamps time to interval.

Parameters
timeTimestamp to clamp.
Returns
clamped timestamp.
static TimeInterval kanzi::TimeInterval::createFromStartTimeAndDuration ( chrono::milliseconds  start,
optional< chrono::milliseconds >  duration 
)
static

Creates interval from start time and duration.

Parameters
startStart timestamp of interval.
durationDuration of interval. Empty optional specifies infinite duration.

The documentation for this struct was generated from the following file: