time_point
template <typename TClock, typename TDuration = typename TClock::duration>
class time_point;Represents a point in time storing a TDuration indicating the time
interval from the start of the TClock’s epoch.
Member types
using clock = TClock
using duration = TDuration
using rep = typename TDuration::rep
using period = typename TDuration::periodConstructors
ETL_CONSTEXPR
time_point()
ETL_NOEXCEPTDescription
Default constructor.
ETL_CONSTEXPR14
explicit time_point(const duration& dur_)
ETL_NOEXCEPTDescription
Construct from a duration.
ETL_CONSTEXPR14
time_point(const time_point& rhs)
ETL_NOEXCEPTDescription
Copy constructor.
template <typename TDuration2>
ETL_CONSTEXPR14
explicit time_point(const time_point<clock, TDuration2>& rhs)
ETL_NOEXCEPTDescription
Copy construct from another time_point with a different duration type.
Assignment
ETL_CONSTEXPR14
time_point& operator =(const time_point& rhs)
ETL_NOEXCEPTDescription
Assignment operator.
Access
ETL_NODISCARD
ETL_CONSTEXPR14 duration time_since_epoch() const
ETL_NOEXCEPTReturn
A duration representing the amount of time between this and the clock’s epoch.
Member arithmetic operators
ETL_CONSTEXPR14 time_point& operator +=(const duration& rhs)
ETL_NOEXCEPTDescription
Adds a duration.
ETL_CONSTEXPR14 time_point& operator -=(const duration& rhs)
ETL_NOEXCEPTDescription
Subtracts a duration.
Constants
ETL_NODISCARD
static ETL_CONSTEXPR14 time_point min()
ETL_NOEXCEPTReturn
A time_point with the smallest possible duration.
ETL_NODISCARD
static ETL_CONSTEXPR14 time_point max()
ETL_NOEXCEPTReturn
A time_point with the largest possible duration.
Rounding
template <typename TToDuration, typename TClock, typename TDuration>
ETL_NODISCARD
ETL_CONSTEXPR14
etl::chrono::time_point<TClock, TToDuration>
floor(const etl::chrono::time_point<TClock, TDuration>& tp)
ETL_NOEXCEPTDescription
Rounds down a duration to the nearest lower precision.
template <typename TToDuration, typename TClock, typename TDuration>
ETL_NODISCARD
ETL_CONSTEXPR14
etl::chrono::time_point<TClock, TToDuration>
ceil(const etl::chrono::time_point<TClock, TDuration>& tp)
ETL_NOEXCEPTDescription
Rounds up a duration to the nearest higher precision.
template <typename TToDuration, typename TClock, typename TDuration>
ETL_NODISCARD
ETL_CONSTEXPR14
etl::chrono::time_point<TClock, TToDuration>
round(const etl::chrono::time_point<TClock, TDuration>& tp)
ETL_NOEXCEPTDescription
Rounds a duration to the nearest precision.
If the duration is exactly halfway, it rounds away from zero.
Casting
template <typename TToDuration, typename TClock, typename TDuration>
ETL_NODISCARD
ETL_CONSTEXPR14
etl::chrono::time_point<TClock, TToDuration>
time_point_cast(const etl::chrono::time_point<TClock, TDuration>& tp)
ETL_NOEXCEPTComparison
ETL_NODISCARD
ETL_CONSTEXPR14 int compare(const time_point& other) const
ETL_NOEXCEPTDescription
Compare day with another.
If time_point < other, returns -1
else if time_point > other, returns 1
else returns 0
Non-member comparison operators
template <typename TClock, typename TDuration1, typename TDuration2>
ETL_CONSTEXPR14
bool operator ==(const time_point<TClock, TDuration1>& lhs,
const time_point<TClock, TDuration2>& rhs)
ETL_NOEXCEPTDescription
Equality operator
template <typename TClock, typename TDuration1, typename TDuration2>
ETL_CONSTEXPR14
bool operator !=(const time_point<TClock, TDuration1>& lhs,
const time_point<TClock, TDuration2>& rhs)
ETL_NOEXCEPTDescription
Inequality operator
template <typename TClock, typename TDuration1, typename TDuration2>
ETL_CONSTEXPR14
bool operator <(const time_point<TClock, TDuration1>& lhs,
const time_point<TClock, TDuration2>& rhs)
ETL_NOEXCEPTDescription
Less-than operator
template <typename TClock, typename TDuration1, typename TDuration2>
ETL_CONSTEXPR14
bool operator <=(const time_point<TClock, TDuration1>& lhs,
const time_point<TClock, TDuration2>& rhs)
ETL_NOEXCEPTDescription
Less-than-equal operator
template <typename TClock, typename TDuration1, typename TDuration2>
ETL_CONSTEXPR14
bool operator >(const time_point<TClock, TDuration1>& lhs,
const time_point<TClock, TDuration2>& rhs)
ETL_NOEXCEPTDescription
Greater-than operator
template <typename TClock, typename TDuration1, typename TDuration2>
ETL_CONSTEXPR14
bool operator >=(const time_point<TClock, TDuration1>& lhs,
const time_point<TClock, TDuration2>& rhs)
ETL_NOEXCEPTDescription
Greater-than-equal operator
template <typename TClock, typename TDuration1, typename TDuration2>
[[nodiscard]] constexpr auto operator <=>(const etl::chrono::time_point<TClock, TDuration1>& lhs,
const etl::chrono::time_point<TClock, TDuration2>& rhs)
noexceptDescription
Spaceship operator
C++20
etl::common_type specialisation
template <typename TClock, typename TDuration1, typename TDuration2>
struct common_type<etl::chrono::time_point<TClock, TDuration1>,
etl::chrono::time_point<TClock, TDuration2>>Description
Defines type, which is the common type of two etl::chrono::time_point.