Class TimePoint

Class Documentation

class TimePoint

Wraps the C++ standard system_clock point in time to provide arithmetic, interactions with Durations and parsing/formatting functions.

The represented time zone is UTC only.

Public Types

typedef SystemClock Clock
typedef std::chrono::time_point<Clock, Duration::Basis> Basis

Public Functions

inline TimePoint()
inline TimePoint(const std::string &str)
TimePoint(const TimePoint&, const Duration&)
inline Duration operator-(const TimePoint &a) const

Calculate the Duration between two TimePoints.

inline TimePoint operator-(const Duration &d) const

Subtract a Duration from this TimePoint.

inline TimePoint &operator+=(const Duration &d)

Add-assign a Duration to this TimePoint (now + 7 days = next week).

inline TimePoint &operator-=(const Duration &d)

Subtract-assign a Duration from this TimePoint (now - 7 days = last week).

inline TimePoint operator+(const Duration &d) const

Add a Duration to a TimePoint and return the new TimePoint.

inline bool operator<=(const TimePoint &a) const
inline bool operator<(const TimePoint &a) const
inline bool operator>=(const TimePoint &a) const
inline bool operator>(const TimePoint &a) const
inline bool operator==(const TimePoint &a) const
inline bool operator!=(const TimePoint &a) const
inline std::istream &parse(std::istream &is)

Set this TimePoint by parsing the characters in an istream as an ISO 8601 date.

inline TimePoint &parse(const std::string &str)

Set this TimePoint by parsing a string as an ISO 8601 date.

inline std::ostream &format(std::ostream &os, std::string formatStr = ymdhmsFormat) const

Print this TimePoint as a formatted date to an ostream.

inline std::string format(std::string formatStr = ymdhmsFormat) const

Return the formatted string representation of this TimePoint.

std::tm *gmtime() const

Public Members

friend Duration

Public Static Attributes

static const std::string ymdFormat = "%Y-%m-%d"
static const std::string doyFormat = "%Y-%j"
static const std::string ymdhmsFormat = ymdFormat + hmsFormat
static const std::string doyhmsFormat = doyFormat + hmsFormat
static const std::string hmsFormat = "T%H:%M:%SZ"