Home | History | Annotate | Download | only in time

Lines Matching defs:TimeDelta

13 // TimeDelta represents a duration of time, internally represented in
26 // void MyFunction(TimeDelta arg);
28 // void MyFunction(const TimeDelta& arg); // Not preferred.
87 class TimeDelta;
94 // Add or subtract |value| from a TimeDelta. The int64_t argument and return
96 BASE_EXPORT int64_t SaturatedAdd(TimeDelta delta, int64_t value);
97 BASE_EXPORT int64_t SaturatedSub(TimeDelta delta, int64_t value);
101 // TimeDelta ------------------------------------------------------------------
103 class BASE_EXPORT TimeDelta {
105 TimeDelta() : delta_(0) {
109 static constexpr TimeDelta FromDays(int days);
110 static constexpr TimeDelta FromHours(int hours);
111 static constexpr TimeDelta FromMinutes(int minutes);
112 static constexpr TimeDelta FromSeconds(int64_t secs);
113 static constexpr TimeDelta FromMilliseconds(int64_t ms);
114 static constexpr TimeDelta FromSecondsD(double secs);
115 static constexpr TimeDelta FromMillisecondsD(double ms);
116 static constexpr TimeDelta FromMicroseconds(int64_t us);
118 static TimeDelta FromTimeSpec(const timespec& ts);
121 static TimeDelta FromQPCValue(LONGLONG qpc_value);
124 // Converts an integer value representing TimeDelta to a class. This is used
125 // when deserializing a |TimeDelta| structure, using a value known to be
128 static TimeDelta FromInternalValue(int64_t delta) { return TimeDelta(delta); }
133 static constexpr TimeDelta Max();
135 // Returns the internal numeric value of the TimeDelta object. Please don't
141 // Returns the magnitude (absolute value) of this TimeDelta.
142 TimeDelta magnitude() const {
147 return TimeDelta((delta_ + mask) ^ mask);
177 TimeDelta& operator=(TimeDelta other) {
183 TimeDelta operator+(TimeDelta other) const {
184 return TimeDelta(time_internal::SaturatedAdd(*this, other.delta_));
186 TimeDelta operator-(TimeDelta other) const {
187 return TimeDelta(time_internal::SaturatedSub(*this, other.delta_));
190 TimeDelta& operator+=(TimeDelta other) {
193 TimeDelta& operator-=(TimeDelta other) {
196 TimeDelta operator-() const {
197 return TimeDelta(-delta_);
202 TimeDelta operator*(T a) const {
206 return TimeDelta(rv.ValueOrDie());
209 return TimeDelta(-std::numeric_limits<int64_t>::max());
210 return TimeDelta(std::numeric_limits<int64_t>::max());
213 TimeDelta operator/(T a) const {
217 return TimeDelta(rv.ValueOrDie());
221 return TimeDelta(-std::numeric_limits<int64_t>::max());
222 return TimeDelta(std::numeric_limits<int64_t>::max());
225 TimeDelta& operator*=(T a) {
229 TimeDelta& operator/=(T a) {
233 int64_t operator/(TimeDelta a) const { return delta_ / a.delta_; }
234 TimeDelta operator%(TimeDelta a) const {
235 return TimeDelta(delta_ % a.delta_);
239 constexpr bool operator==(TimeDelta other) const {
242 constexpr bool operator!=(TimeDelta other) const {
245 constexpr bool operator<(TimeDelta other) const {
248 constexpr bool operator<=(TimeDelta other) const {
251 constexpr bool operator>(TimeDelta other) const {
254 constexpr bool operator>=(TimeDelta other) const {
260 constexpr TimeDelta(const TimeDelta& other) : delta_(other.delta_) {}
264 friend int64_t time_internal::SaturatedAdd(TimeDelta delta, int64_t value);
265 friend int64_t time_internal::SaturatedSub(TimeDelta delta, int64_t value);
270 constexpr explicit TimeDelta(int64_t delta_us) : delta_(delta_us) {}
273 static constexpr TimeDelta FromDouble(double value);
277 static constexpr TimeDelta FromProduct(int64_t value, int64_t positive_value);
284 inline TimeDelta operator*(T a, TimeDelta td) {
289 BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeDelta time_delta);
350 TimeDelta since_origin() const { return TimeDelta::FromMicroseconds(us_); }
358 TimeDelta operator-(TimeClass other) const {
359 return TimeDelta::FromMicroseconds(us_ - other.us_);
363 TimeClass operator+(TimeDelta delta) const {
366 TimeClass operator-(TimeDelta delta) const {
371 TimeClass& operator+=(TimeDelta delta) {
374 TimeClass& operator-=(TimeDelta delta) {
414 inline TimeClass operator+(TimeDelta delta, TimeClass t) {
624 constexpr TimeDelta TimeDelta::FromDays(int days) {
627 : TimeDelta(days * Time::kMicrosecondsPerDay);
631 constexpr TimeDelta TimeDelta::FromHours(int hours) {
634 : TimeDelta(hours * Time::kMicrosecondsPerHour);
638 constexpr TimeDelta TimeDelta::FromMinutes(int minutes) {
641 : TimeDelta(minutes * Time::kMicrosecondsPerMinute);
645 constexpr TimeDelta TimeDelta::FromSeconds(int64_t secs) {
650 constexpr TimeDelta TimeDelta::FromMilliseconds(int64_t ms) {
655 constexpr TimeDelta TimeDelta::FromSecondsD(double secs) {
660 constexpr TimeDelta TimeDelta::FromMillisecondsD(double ms) {
665 constexpr TimeDelta TimeDelta::FromMicroseconds(int64_t us) {
666 return TimeDelta(us);
670 constexpr TimeDelta TimeDelta::Max() {
671 return TimeDelta(std::numeric_limits<int64_t>::max());
675 constexpr TimeDelta TimeDelta::FromDouble(double value) {
682 : TimeDelta(static_cast<int64_t>(value));
686 constexpr TimeDelta TimeDelta::FromProduct(int64_t value,
699 : TimeDelta(value * positive_value));
766 TimeDelta tick_interval) const;