#ifndef FLUTTER_FML_TIME_TIME_POINT_H_
#define FLUTTER_FML_TIME_TIME_POINT_H_
#include <stdint.h>
#include <iosfwd>
#include "flutter/fml/time/time_delta.h"
namespace fml {
class TimePoint {
public:
constexpr TimePoint() = default;
static TimePoint Now();
static constexpr TimePoint Min() {
return TimePoint(std::numeric_limits<int64_t>::min());
}
static constexpr TimePoint Max() {
return TimePoint(std::numeric_limits<int64_t>::max());
}
static constexpr TimePoint FromEpochDelta(TimeDelta ticks) {
return TimePoint(ticks.ToNanoseconds());
}
TimeDelta ToEpochDelta() const { return TimeDelta::FromNanoseconds(ticks_); }
TimeDelta operator-(TimePoint other) const {
return TimeDelta::FromNanoseconds(ticks_ - other.ticks_);
}
TimePoint operator+(TimeDelta duration) const {
return TimePoint(ticks_ + duration.ToNanoseconds());
}
TimePoint operator-(TimeDelta duration) const {
return TimePoint(ticks_ - duration.ToNanoseconds());
}
bool operator==(TimePoint other) const { return ticks_ == other.ticks_; }
bool operator!=(TimePoint other) const { return ticks_ != other.ticks_; }
bool operator<(TimePoint other) const { return ticks_ < other.ticks_; }
bool operator<=(TimePoint other) const { return ticks_ <= other.ticks_; }
bool operator>(TimePoint other) const { return ticks_ > other.ticks_; }
bool operator>=(TimePoint other) const { return ticks_ >= other.ticks_; }
private:
explicit constexpr TimePoint(int64_t ticks) : ticks_(ticks) {}
int64_t ticks_ = 0;
};
}
#endif