Home | History | Annotate | Download | only in time

Lines Matching full:time

5 #include "base/time/time.h"
8 #include <sys/time.h>
9 #include <time.h>
86 (static_cast<int64>(ts.tv_sec) * base::Time::kMicrosecondsPerSecond) +
87 (static_cast<int64>(ts.tv_nsec) / base::Time::kNanosecondsPerMicrosecond);
103 if (microseconds >= Time::kMicrosecondsPerSecond) {
105 microseconds -= seconds * Time::kMicrosecondsPerSecond;
109 static_cast<long>(microseconds * Time::kNanosecondsPerMicrosecond)};
114 // The Time routines in this file use standard POSIX routines, or almost-
118 // Time -----------------------------------------------------------------------
121 // so that our time representations match across all platforms. See bug 14734.
122 // irb(main):010:0> Time.at(0).getutc()
124 // irb(main):011:0> Time.at(-11644473600).getutc()
129 const int64 Time::kWindowsEpochDeltaMicroseconds =
130 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond;
132 // Some functions in time.cc use time_t directly, so we provide an offset
135 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds;
138 Time Time::Now() {
142 DCHECK(0) << "Could not determine time of day";
146 return Time();
151 return Time((tv.tv_sec * kMicrosecondsPerSecond + tv.tv_usec) +
156 Time Time::NowFromSystemTime() {
157 // Just use Now() because Now() returns the system time.
161 void Time::Explode(bool is_local, Exploded* exploded) const {
162 // Time stores times with microsecond resolution, but Exploded only carries
201 Time Time::FromExploded(bool is_local, const Exploded& exploded) {
232 // Get the time values with tm_isdst == 0 and 1, then select the closest one
243 // E.g. "CLST" (Chile Summer Time) returns -1 for 'tm_isdt == 1'.
254 // than failing here or ignoring the overflow case and treating each time
259 // time indicating 1 second prior to the epoch. (1970 is allowed to handle
260 // time zone and DST offsets.) Otherwise, return the most future or past
261 // time representable. Assumes the time_t epoch is 1970-01-01 00:00:00 UTC.
265 // proper round-tripping between exploded and counter-type time
269 // When representing the most distant time in the future, add in an extra
270 // 999ms to avoid the time being less than any other possible value that
292 return Time((milliseconds * kMicrosecondsPerMillisecond) +
336 (static_cast<int64>(ts.tv_sec) * Time::kMicrosecondsPerSecond) +
337 (static_cast<int64>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond);
354 Time Time::FromTimeVal(struct timeval t) {
355 DCHECK_LT(t.tv_usec, static_cast<int>(Time::kMicrosecondsPerSecond));
358 return Time();
359 if (t.tv_usec == static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1 &&
362 return Time(
363 (static_cast<int64>(t.tv_sec) * Time::kMicrosecondsPerSecond) +
368 struct timeval Time::ToTimeVal() const {
377 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
381 result.tv_sec = us / Time::kMicrosecondsPerSecond;
382 result.tv_usec = us % Time::kMicrosecondsPerSecond;