Kanzi 3.9.10
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.
 
bool contains (chrono::milliseconds time) const
 Determines whether the interval contains specified timestamp.
 
optional< chrono::milliseconds > getDuration () const
 Gets the duration of interval.
 
optional< chrono::milliseconds > getEnd () const
 Gets end timestamp.
 
optional< chrono::milliseconds > getStart () const
 Gets start timestamp.
 
bool isEnd (chrono::milliseconds time) const
 Determines whether specified timestamp equals to end of interval.
 
bool isStart (chrono::milliseconds time) const
 Determines whether specified timestamp equals to start of interval.
 
 TimeInterval ()
 Default constructor.
 
 TimeInterval (optional< chrono::milliseconds > start, optional< chrono::milliseconds > end)
 Constructor.
 

Static Public Member Functions

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

Detailed Description

Interval in time specified as start and end timestamps.

Constructor & Destructor Documentation

◆ TimeInterval() [1/2]

kanzi::TimeInterval::TimeInterval ( )
explicit

Default constructor.

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

◆ TimeInterval() [2/2]

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

◆ getStart()

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

Gets start timestamp.

Empty optional specifies negative infinity.

Returns
start timestamp.

◆ getEnd()

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

Gets end timestamp.

Empty optional specifies positive infinity.

Returns
end timestamp.

◆ getDuration()

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

Gets the duration of interval.

Empty optional specifies infinite duration.

Returns
end timestamp.

◆ contains()

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.

◆ isStart()

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.

◆ isEnd()

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.

◆ clampToInterval()

chrono::milliseconds kanzi::TimeInterval::clampToInterval ( chrono::milliseconds time) const

Clamps time to interval.

Parameters
timeTimestamp to clamp.
Returns
clamped timestamp.

◆ createFromStartTimeAndDuration()

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: