libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Duration Class Reference

Time duration with nanosecond precision. More...

#include <duration.h>

Public Member Functions

 Duration ()
 Default constructor. Creates a zero duration.
 
int64_t hours () const
 Returns the total number of whole hours.
 
int64_t minutes () const
 Returns the total number of whole minutes.
 
int64_t seconds () const
 Returns the total number of whole seconds.
 
int64_t milliseconds () const
 Returns the total number of whole milliseconds.
 
int64_t microseconds () const
 Returns the total number of whole microseconds.
 
int64_t nanoseconds () const
 Returns the total number of nanoseconds.
 
double toSecondsDouble () const
 Returns the duration as a fractional number of seconds.
 
bool isZero () const
 Returns true if the duration is exactly zero.
 
bool isNegative () const
 Returns true if the duration is negative.
 
String toString () const
 Returns a human-readable representation (e.g. "1h 23m 45s").
 
Duration operator+ (const Duration &o) const
 Addition operator.
 
Duration operator- (const Duration &o) const
 Subtraction operator.
 
Duration operator* (int64_t s) const
 Scalar multiplication operator.
 
Duration operator/ (int64_t s) const
 Scalar division operator.
 
bool operator== (const Duration &o) const
 Equality comparison.
 
bool operator!= (const Duration &o) const
 Inequality comparison.
 
bool operator< (const Duration &o) const
 Less-than comparison.
 
bool operator> (const Duration &o) const
 Greater-than comparison.
 
bool operator<= (const Duration &o) const
 Less-than-or-equal comparison.
 
bool operator>= (const Duration &o) const
 Greater-than-or-equal comparison.
 

Static Public Member Functions

static Duration fromHours (int64_t h)
 Creates a Duration from hours.
 
static Duration fromMinutes (int64_t m)
 Creates a Duration from minutes.
 
static Duration fromSeconds (int64_t s)
 Creates a Duration from seconds.
 
static Duration fromMilliseconds (int64_t ms)
 Creates a Duration from milliseconds.
 
static Duration fromMicroseconds (int64_t us)
 Creates a Duration from microseconds.
 
static Duration fromNanoseconds (int64_t ns)
 Creates a Duration from nanoseconds.
 

Detailed Description

Time duration with nanosecond precision.

Simple value type wrapping std::chrono::nanoseconds. Provides static factories for construction and accessors for various time units. No PROMEKI_SHARED_FINAL.

Member Function Documentation

◆ fromHours()

static Duration Duration::fromHours ( int64_t  h)
inlinestatic

Creates a Duration from hours.

Parameters
hNumber of hours.
Returns
The Duration.

◆ fromMicroseconds()

static Duration Duration::fromMicroseconds ( int64_t  us)
inlinestatic

Creates a Duration from microseconds.

Parameters
usNumber of microseconds.
Returns
The Duration.

◆ fromMilliseconds()

static Duration Duration::fromMilliseconds ( int64_t  ms)
inlinestatic

Creates a Duration from milliseconds.

Parameters
msNumber of milliseconds.
Returns
The Duration.

◆ fromMinutes()

static Duration Duration::fromMinutes ( int64_t  m)
inlinestatic

Creates a Duration from minutes.

Parameters
mNumber of minutes.
Returns
The Duration.

◆ fromNanoseconds()

static Duration Duration::fromNanoseconds ( int64_t  ns)
inlinestatic

Creates a Duration from nanoseconds.

Parameters
nsNumber of nanoseconds.
Returns
The Duration.

◆ fromSeconds()

static Duration Duration::fromSeconds ( int64_t  s)
inlinestatic

Creates a Duration from seconds.

Parameters
sNumber of seconds.
Returns
The Duration.

◆ hours()

int64_t Duration::hours ( ) const
inline

Returns the total number of whole hours.

Returns
Hours as int64_t.

◆ isNegative()

bool Duration::isNegative ( ) const
inline

Returns true if the duration is negative.

Returns
True if negative.

◆ isZero()

bool Duration::isZero ( ) const
inline

Returns true if the duration is exactly zero.

Returns
True if zero.

◆ microseconds()

int64_t Duration::microseconds ( ) const
inline

Returns the total number of whole microseconds.

Returns
Microseconds as int64_t.

◆ milliseconds()

int64_t Duration::milliseconds ( ) const
inline

Returns the total number of whole milliseconds.

Returns
Milliseconds as int64_t.

◆ minutes()

int64_t Duration::minutes ( ) const
inline

Returns the total number of whole minutes.

Returns
Minutes as int64_t.

◆ nanoseconds()

int64_t Duration::nanoseconds ( ) const
inline

Returns the total number of nanoseconds.

Returns
Nanoseconds as int64_t.

◆ seconds()

int64_t Duration::seconds ( ) const
inline

Returns the total number of whole seconds.

Returns
Seconds as int64_t.

◆ toSecondsDouble()

double Duration::toSecondsDouble ( ) const
inline

Returns the duration as a fractional number of seconds.

Returns
Seconds as a double.

◆ toString()

String Duration::toString ( ) const

Returns a human-readable representation (e.g. "1h 23m 45s").

Returns
Formatted string.

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