Poco

class Timespan

Library: Foundation
Package: DateTime
Header: Poco/Timespan.h

Description

A class that represents time spans up to microsecond resolution.

Member Summary

Member Functions: assign, days, hours, microseconds, milliseconds, minutes, operator !=, operator +, operator +=, operator -, operator -=, operator <, operator <=, operator =, operator ==, operator >, operator >=, seconds, swap, totalHours, totalMicroseconds, totalMilliseconds, totalMinutes, totalSeconds, useconds

Types Aliases

TimeDiff

using TimeDiff = Timestamp::TimeDiff;

Constructors

Timespan

Timespan();

Creates a zero Timespan.

Timespan

Timespan(
    TimeDiff microseconds
);

Creates a Timespan.

Timespan

Timespan(
    const Timespan & timespan
);

Creates a Timespan from another one.

Timespan inline

template < class T, class Period > Timespan(
    const std::chrono::duration < T, Period > & dtime
);

Creates a Timespan from std::chrono::duration

Timespan

Timespan(
    long seconds,
    long microseconds
);

Creates a Timespan. Useful for creating a Timespan from a struct timeval.

Timespan

Timespan(
    int days,
    int hours,
    int minutes,
    int seconds,
    int microSeconds
);

Creates a Timespan.

Destructor

~Timespan inline

~Timespan();

Destroys the Timespan.

Member Functions

assign

Timespan & assign(
    int days,
    int hours,
    int minutes,
    int seconds,
    int microSeconds
);

Assigns a new span.

assign

Timespan & assign(
    long seconds,
    long microseconds
);

Assigns a new span. Useful for assigning from a struct timeval.

assign inline

template < class T, class Period > Timespan & assign(
    const std::chrono::duration < T, Period > & dtime
);

Assigns a new span from std::chrono::duration.

days inline

int days() const;

Returns the number of days.

hours inline

int hours() const;

Returns the number of hours (0 to 23).

microseconds inline

int microseconds() const;

Returns the fractions of a millisecond in microseconds (0 to 999).

milliseconds inline

int milliseconds() const;

Returns the number of milliseconds (0 to 999).

minutes inline

int minutes() const;

Returns the number of minutes (0 to 59).

operator != inline

bool operator != (
    const Timespan & ts
) const;

operator !=

bool operator != (
    TimeDiff microSeconds
) const;

operator +

Timespan operator + (
    const Timespan & d
) const;

operator +

Timespan operator + (
    TimeDiff microSeconds
) const;

operator +=

Timespan & operator += (
    const Timespan & d
);

operator +=

Timespan & operator += (
    TimeDiff microSeconds
);

operator -

Timespan operator - (
    const Timespan & d
) const;

operator -

Timespan operator - (
    TimeDiff microSeconds
) const;

operator -=

Timespan & operator -= (
    const Timespan & d
);

operator -=

Timespan & operator -= (
    TimeDiff microSeconds
);

operator < inline

bool operator < (
    const Timespan & ts
) const;

operator <

bool operator < (
    TimeDiff microSeconds
) const;

operator <= inline

bool operator <= (
    const Timespan & ts
) const;

operator <=

bool operator <= (
    TimeDiff microSeconds
) const;

operator =

Timespan & operator = (
    const Timespan & timespan
);

Assignment operator.

operator =

Timespan & operator = (
    TimeDiff microseconds
);

Assignment operator.

operator == inline

bool operator == (
    const Timespan & ts
) const;

operator ==

bool operator == (
    TimeDiff microSeconds
) const;

operator > inline

bool operator > (
    const Timespan & ts
) const;

operator >

bool operator > (
    TimeDiff microSeconds
) const;

operator >= inline

bool operator >= (
    const Timespan & ts
) const;

operator >=

bool operator >= (
    TimeDiff microSeconds
) const;

seconds inline

int seconds() const;

Returns the number of seconds (0 to 59).

swap

void swap(
    Timespan & timespan
) noexcept;

Swaps the Timespan with another one.

totalHours inline

int totalHours() const;

Returns the total number of hours.

totalMicroseconds inline

TimeDiff totalMicroseconds() const;

Returns the total number of microseconds.

totalMilliseconds inline

TimeDiff totalMilliseconds() const;

Returns the total number of milliseconds.

totalMinutes inline

int totalMinutes() const;

Returns the total number of minutes.

totalSeconds inline

int totalSeconds() const;

Returns the total number of seconds.

useconds inline

int useconds() const;

Returns the fractions of a second in microseconds (0 to 999999).

Variables

DAYS static

static const TimeDiff DAYS;

The number of microseconds in a day.

HOURS static

static const TimeDiff HOURS;

The number of microseconds in a hour.

MILLISECONDS static

static const TimeDiff MILLISECONDS;

The number of microseconds in a millisecond.

MINUTES static

static const TimeDiff MINUTES;

The number of microseconds in a minute.

SECONDS static

static const TimeDiff SECONDS;

The number of microseconds in a second.