Lines Matching full:time
5 #include "base/time/time.h"
7 #include <sys/time.h>
8 #include <time.h>
81 (static_cast<int64>(ts.tv_sec) * base::Time::kMicrosecondsPerSecond) +
82 (static_cast<int64>(ts.tv_nsec) / base::Time::kNanosecondsPerMicrosecond);
98 if (microseconds >= Time::kMicrosecondsPerSecond) {
100 microseconds -= seconds * Time::kMicrosecondsPerSecond;
104 static_cast<long>(microseconds * Time::kNanosecondsPerMicrosecond)};
109 // The Time routines in this file use standard POSIX routines, or almost-
113 // Time -----------------------------------------------------------------------
116 // so that our time representations match across all platforms. See bug 14734.
117 // irb(main):010:0> Time.at(0).getutc()
119 // irb(main):011:0> Time.at(-11644473600).getutc()
123 kWindowsEpochDeltaSeconds * Time::kMillisecondsPerSecond;
126 const int64 Time::kWindowsEpochDeltaMicroseconds =
127 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond;
129 // Some functions in time.cc use time_t directly, so we provide an offset
132 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds;
135 Time Time::Now() {
139 DCHECK(0) << "Could not determine time of day";
143 return Time();
148 return Time((tv.tv_sec * kMicrosecondsPerSecond + tv.tv_usec) +
153 Time Time::NowFromSystemTime() {
154 // Just use Now() because Now() returns the system time.
158 void Time::Explode(bool is_local, Exploded* exploded) const {
159 // Time stores times with microsecond resolution, but Exploded only carries
198 Time Time::FromExploded(bool is_local, const Exploded& exploded) {
229 // Get the time values with tm_isdst == 0 and 1, then select the closest one
240 // E.g. "CLST" (Chile Summer Time) returns -1 for 'tm_isdt == 1'.
251 // than failing here or ignoring the overflow case and treating each time
256 // time indicating 1 second prior to the epoch. (1970 is allowed to handle
257 // time zone and DST offsets.) Otherwise, return the most future or past
258 // time representable. Assumes the time_t epoch is 1970-01-01 00:00:00 UTC.
262 // proper round-tripping between exploded and counter-type time
266 // When representing the most distant time in the future, add in an extra
267 // 999ms to avoid the time being less than any other possible value that
289 return Time((milliseconds * kMicrosecondsPerMillisecond) +
331 (static_cast<int64>(ts.tv_sec) * Time::kMicrosecondsPerSecond) +
332 (static_cast<int64>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond);
349 Time Time::FromTimeVal(struct timeval t) {
350 DCHECK_LT(t.tv_usec, static_cast<int>(Time::kMicrosecondsPerSecond));
353 return Time();
354 if (t.tv_usec == static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1 &&
357 return Time(
358 (static_cast<int64>(t.tv_sec) * Time::kMicrosecondsPerSecond) +
363 struct timeval Time::ToTimeVal() const {
372 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
376 result.tv_sec = us / Time::kMicrosecondsPerSecond;
377 result.tv_usec = us % Time::kMicrosecondsPerSecond;