8#ifndef SEN_CORE_BASE_TIMESTAMP_H
9#define SEN_CORE_BASE_TIMESTAMP_H
32 constexpr explicit
TimeStamp(
Duration timeSinceEpoch) noexcept: timeSinceEpoch_(timeSinceEpoch) {}
36 constexpr SEN_COPY_CONSTRUCT(
TimeStamp) = default;
37 constexpr SEN_MOVE_CONSTRUCT(
TimeStamp) = default;
50 constexpr bool operator==(
const TimeStamp& other)
const noexcept {
return timeSinceEpoch_ == other.timeSinceEpoch_; }
53 constexpr bool operator!=(
const TimeStamp& other)
const noexcept {
return timeSinceEpoch_ != other.timeSinceEpoch_; }
56 constexpr bool operator<(
const TimeStamp& other)
const noexcept {
return timeSinceEpoch_ < other.timeSinceEpoch_; }
59 constexpr bool operator<=(
const TimeStamp& other)
const noexcept {
return timeSinceEpoch_ <= other.timeSinceEpoch_; }
62 constexpr bool operator>(
const TimeStamp& other)
const noexcept {
return timeSinceEpoch_ > other.timeSinceEpoch_; }
65 constexpr bool operator>=(
const TimeStamp& other)
const noexcept {
return timeSinceEpoch_ >= other.timeSinceEpoch_; }
70 timeSinceEpoch_ += other;
80 timeSinceEpoch_ -= other;
106static_assert(
sizeof(
TimeStamp) == 8,
"TimeStamp should be 8 bytes");
107static_assert(std::is_trivially_copyable_v<TimeStamp>);
A time duration.
Definition duration.h:25
Base::ValueType ValueType
Definition duration.h:31
Result<T, E> is a template type that can be used to return and propagate errors. The intent is to rep...
Definition result.h:135
A point in time.
Definition timestamp.h:26
std::string toUtcString() const
UTC string representation of this time point.
TimeStamp & operator+=(const Duration &other) noexcept
Adds other to *this and returns *this.
Definition timestamp.h:68
constexpr Duration sinceEpoch() const noexcept
Time passed since 1 January 1970 UTC.
Definition timestamp.h:46
constexpr TimeStamp operator+(const Duration &other) const noexcept
Returns a TimeStamp of *this + other.
Definition timestamp.h:75
constexpr bool operator>=(const TimeStamp &other) const noexcept
True if *this is greater or equal than other.
Definition timestamp.h:65
constexpr bool operator==(const TimeStamp &other) const noexcept
Compares two Timestamps to determine if they are equal.
Definition timestamp.h:50
static Result< TimeStamp, std::string > make(const std::string_view iso8601Time)
constexpr TimeStamp() noexcept=default
~TimeStamp() noexcept=default
constexpr bool operator!=(const TimeStamp &other) const noexcept
Compares two Timestamps to determine if they are not equal.
Definition timestamp.h:53
TimeStamp & operator-=(const Duration &other) noexcept
Removes other from *this and returns *this.
Definition timestamp.h:78
constexpr Duration operator-(const TimeStamp &other) const noexcept
Returns a Duration of *this - other.
Definition timestamp.h:88
constexpr bool operator<=(const TimeStamp &other) const noexcept
True if *this is less or equal than other.
Definition timestamp.h:59
Duration::ValueType ValueType
Definition timestamp.h:28
constexpr TimeStamp operator-(const Duration &other) const noexcept
Returns a TimeStamp of *this - other.
Definition timestamp.h:85
constexpr bool operator>(const TimeStamp &other) const noexcept
True if *this is greater than other.
Definition timestamp.h:62
constexpr bool operator<(const TimeStamp &other) const noexcept
True if *this is less than other.
Definition timestamp.h:56
std::string toLocalString() const
Local string representation of this time point.
Utility to indicate that your class wants to be passed by value in some of the library calls.
Definition class_helpers.h:34