Zth (libzth)
zth::Timestamp Class Reference

Convenient wrapper around struct timespec that contains an absolute timestamp. More...

#include <time.h>

Public Member Functions

constexpr Timestamp () noexcept
 
constexpr Timestamp (struct timespec const &ts) noexcept
 
constexpr Timestamp (time_t sec, long nsec=0) noexcept
 
 Timestamp (TimeInterval const &ti)
 
constexpr struct timespec const & ts () const noexcept
 
constexpr operator struct timespec const & () const noexcept
 
constexpr bool isBefore (Timestamp const &t) const noexcept
 
constexpr bool isAfter (Timestamp const &t) const noexcept
 
bool hasPassed () const noexcept
 
constexpr bool operator== (Timestamp const &rhs) const noexcept
 
constexpr bool operator!= (Timestamp const &rhs) const noexcept
 
constexpr bool operator< (Timestamp const &rhs) const noexcept
 
constexpr bool operator<= (Timestamp const &rhs) const noexcept
 
constexpr bool operator> (Timestamp const &rhs) const noexcept
 
constexpr bool operator>= (Timestamp const &rhs) const noexcept
 
constexpr TimeInterval timeTo (Timestamp const &t) const
 
TimeInterval passed () const
 
constexpr void add (TimeInterval const &dt) noexcept
 
constexpr Timestampoperator+= (TimeInterval const &dt) noexcept
 
constexpr Timestamp operator+ (TimeInterval const &dt) const noexcept
 
constexpr Timestampoperator-= (TimeInterval const &dt) noexcept
 
constexpr Timestamp operator- (TimeInterval const &dt) const noexcept
 
constexpr TimeInterval operator- (Timestamp const &rhs) const noexcept
 
constexpr bool isNull () const noexcept
 

Static Public Member Functions

static Timestamp now ()
 
static constexpr Timestamp null () noexcept
 

Detailed Description

Convenient wrapper around struct timespec that contains an absolute timestamp.

Examples
5_perf.cpp, daemon_pattern.cpp, fsm14.cpp, and measure.cpp.

Definition at line 527 of file time.h.

Constructor & Destructor Documentation

◆ Timestamp() [1/4]

constexpr zth::Timestamp::Timestamp ( )
inlineconstexprnoexcept

Definition at line 531 of file time.h.

◆ Timestamp() [2/4]

constexpr zth::Timestamp::Timestamp ( struct timespec const &  ts)
inlineconstexprnoexcept

Definition at line 536 of file time.h.

◆ Timestamp() [3/4]

constexpr zth::Timestamp::Timestamp ( time_t  sec,
long  nsec = 0 
)
inlineexplicitconstexprnoexcept

Definition at line 540 of file time.h.

◆ Timestamp() [4/4]

zth::Timestamp::Timestamp ( TimeInterval const &  ti)
inline

Definition at line 548 of file time.h.

Member Function Documentation

◆ add()

constexpr void zth::Timestamp::add ( TimeInterval const &  dt)
inlineconstexprnoexcept

Definition at line 637 of file time.h.

◆ hasPassed()

bool zth::Timestamp::hasPassed ( ) const
inlinenoexcept

Definition at line 583 of file time.h.

◆ isAfter()

constexpr bool zth::Timestamp::isAfter ( Timestamp const &  t) const
inlineconstexprnoexcept

Definition at line 578 of file time.h.

◆ isBefore()

constexpr bool zth::Timestamp::isBefore ( Timestamp const &  t) const
inlineconstexprnoexcept

Definition at line 572 of file time.h.

◆ isNull()

constexpr bool zth::Timestamp::isNull ( ) const
inlineconstexprnoexcept

Definition at line 679 of file time.h.

◆ now()

static Timestamp zth::Timestamp::now ( )
inlinestatic
Examples
5_perf.cpp, daemon_pattern.cpp, fsm14.cpp, and measure.cpp.

Definition at line 554 of file time.h.

◆ null()

static constexpr Timestamp zth::Timestamp::null ( )
inlinestaticconstexprnoexcept

Definition at line 674 of file time.h.

◆ operator struct timespec const &()

constexpr zth::Timestamp::operator struct timespec const & ( ) const
inlineconstexprnoexcept

Definition at line 567 of file time.h.

◆ operator!=()

constexpr bool zth::Timestamp::operator!= ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 593 of file time.h.

◆ operator+()

constexpr Timestamp zth::Timestamp::operator+ ( TimeInterval const &  dt) const
inlineconstexprnoexcept

Definition at line 651 of file time.h.

◆ operator+=()

constexpr Timestamp& zth::Timestamp::operator+= ( TimeInterval const &  dt)
inlineconstexprnoexcept

Definition at line 645 of file time.h.

◆ operator-() [1/2]

constexpr Timestamp zth::Timestamp::operator- ( TimeInterval const &  dt) const
inlineconstexprnoexcept

Definition at line 663 of file time.h.

◆ operator-() [2/2]

constexpr TimeInterval zth::Timestamp::operator- ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 669 of file time.h.

◆ operator-=()

constexpr Timestamp& zth::Timestamp::operator-= ( TimeInterval const &  dt)
inlineconstexprnoexcept

Definition at line 657 of file time.h.

◆ operator<()

constexpr bool zth::Timestamp::operator< ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 597 of file time.h.

◆ operator<=()

constexpr bool zth::Timestamp::operator<= ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 601 of file time.h.

◆ operator==()

constexpr bool zth::Timestamp::operator== ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 588 of file time.h.

◆ operator>()

constexpr bool zth::Timestamp::operator> ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 605 of file time.h.

◆ operator>=()

constexpr bool zth::Timestamp::operator>= ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 609 of file time.h.

◆ passed()

TimeInterval zth::Timestamp::passed ( ) const
inline

Definition at line 620 of file time.h.

◆ timeTo()

constexpr TimeInterval zth::Timestamp::timeTo ( Timestamp const &  t) const
inlineconstexpr

Definition at line 614 of file time.h.

◆ ts()

constexpr struct timespec const& zth::Timestamp::ts ( ) const
inlinenoexcept

Definition at line 563 of file time.h.


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