mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 19:25:53 +02:00
Merge pull request #180 from syvex/TimestampTimespanOperators
Add operators to Timestamp for Timespan.
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
class Timespan;
|
||||||
|
|
||||||
class Foundation_API Timestamp
|
class Foundation_API Timestamp
|
||||||
/// A Timestamp stores a monotonic* time value
|
/// A Timestamp stores a monotonic* time value
|
||||||
@@ -95,10 +96,14 @@ public:
|
|||||||
bool operator <= (const Timestamp& ts) const;
|
bool operator <= (const Timestamp& ts) const;
|
||||||
|
|
||||||
Timestamp operator + (TimeDiff d) const;
|
Timestamp operator + (TimeDiff d) const;
|
||||||
|
Timestamp operator + (const Timespan& span) const;
|
||||||
Timestamp operator - (TimeDiff d) const;
|
Timestamp operator - (TimeDiff d) const;
|
||||||
|
Timestamp operator - (const Timespan& span) const;
|
||||||
TimeDiff operator - (const Timestamp& ts) const;
|
TimeDiff operator - (const Timestamp& ts) const;
|
||||||
Timestamp& operator += (TimeDiff d);
|
Timestamp& operator += (TimeDiff d);
|
||||||
|
Timestamp& operator += (const Timespan& span);
|
||||||
Timestamp& operator -= (TimeDiff d);
|
Timestamp& operator -= (TimeDiff d);
|
||||||
|
Timestamp& operator -= (const Timespan& span);
|
||||||
|
|
||||||
std::time_t epochTime() const;
|
std::time_t epochTime() const;
|
||||||
/// Returns the timestamp expressed in time_t.
|
/// Returns the timestamp expressed in time_t.
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
|
#include "Poco/Timespan.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX)
|
||||||
@@ -256,6 +257,30 @@ void Timestamp::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Timestamp Timestamp::operator + (const Timespan& span) const
|
||||||
|
{
|
||||||
|
return *this + span.totalMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Timestamp Timestamp::operator - (const Timespan& span) const
|
||||||
|
{
|
||||||
|
return *this - span.totalMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Timestamp& Timestamp::operator += (const Timespan& span)
|
||||||
|
{
|
||||||
|
return *this += span.totalMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Timestamp& Timestamp::operator -= (const Timespan& span)
|
||||||
|
{
|
||||||
|
return *this -= span.totalMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user