Class Poco::Timespan
Author: Applied Informatics Software Engineering GmbH and Contributors

# 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

### TimeDiff

typedef Timestamp::TimeDiff 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

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

~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.

### days

int days() const;

Returns the number of days.

### hours

int hours() const;

Returns the number of hours (0 to 23).

### microseconds

int microseconds() const;

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

### milliseconds

int milliseconds() const;

Returns the number of milliseconds (0 to 999).

### minutes

int minutes() const;

Returns the number of minutes (0 to 59).

### operator !=

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 <

bool operator < (
const Timespan & ts
) const;

### operator <

bool operator < (
TimeDiff microSeconds
) const;

### operator <=

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 ==

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

### operator ==

bool operator == (
TimeDiff microSeconds
) const;

### operator >

bool operator > (
const Timespan & ts
) const;

### operator >

bool operator > (
TimeDiff microSeconds
) const;

### operator >=

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

### operator >=

bool operator >= (
TimeDiff microSeconds
) const;

### seconds

int seconds() const;

Returns the number of seconds (0 to 59).

### swap

void swap(
Timespan & timespan
);

Swaps the Timespan with another one.

### totalHours

int totalHours() const;

Returns the total number of hours.

### totalMicroseconds

TimeDiff totalMicroseconds() const;

Returns the total number of microseconds.

### totalMilliseconds

TimeDiff totalMilliseconds() const;

Returns the total number of milliseconds.

### totalMinutes

int totalMinutes() const;

Returns the total number of minutes.

### totalSeconds

int totalSeconds() const;

Returns the total number of seconds.

### useconds

int useconds() const;

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

## Variables

### DAYS

static const TimeDiff DAYS;

The number of microseconds in a day.

### HOURS

static const TimeDiff HOURS;

The number of microseconds in a hour.

### MILLISECONDS

static const TimeDiff MILLISECONDS;

The number of microseconds in a millisecond.

### MINUTES

static const TimeDiff MINUTES;

The number of microseconds in a minute.

### SECONDS

static const TimeDiff SECONDS;

The number of microseconds in a second.