Home | History | Annotate | Download | only in time

Lines Matching full:time

5 #include "base/time/time.h"
7 #include <time.h>
16 using base::Time;
20 // Specialized test fixture allowing time strings without timezones to be
21 // tested by comparing them to a known time in the local zone.
28 // must be a time guaranteed to be outside of a DST fallback hour in
44 comparison_time_local_ = Time::FromTimeT(converted_time);
47 comparison_time_pdt_ = Time::FromTimeT(1192477500);
50 Time comparison_time_local_;
51 Time comparison_time_pdt_;
56 // C library time and exploded time.
57 time_t now_t_1 = time(NULL);
66 Time our_time_1 = Time::FromTimeT(now_t_1);
67 Time::Exploded exploded;
70 // This will test both our exploding and our time_t -> Time conversion.
78 // Convert exploded back to the time struct.
79 Time our_time_2 = Time::FromLocalExploded(exploded);
85 EXPECT_EQ(10, Time().FromTimeT(10).ToTimeT());
86 EXPECT_EQ(10.0, Time().FromTimeT(10).ToDoubleT());
89 EXPECT_EQ(0, Time().ToTimeT());
90 EXPECT_EQ(0, Time::FromTimeT(0).ToInternalValue());
93 // Test conversions to/from javascript time.
95 Time epoch = Time::FromJsTime(0.0);
96 EXPECT_EQ(epoch, Time::UnixEpoch());
97 Time t = Time::FromJsTime(700000.3);
99 t = Time::FromDoubleT(800.73);
105 Time now = Time::Now();
106 Time also_now = Time::FromTimeVal(now.ToTimeVal());
114 Time now = Time::NowFromSystemTime();
115 Time::Exploded exploded1 = {0};
118 Time time = Time::FromUTCExploded(exploded1);
119 Time::Exploded exploded2 = {0};
120 time.UTCExplode(&exploded2);
125 Time zero_time(Time::FromTimeT(0));
132 Time a = Time::Now();
133 Time::Exploded exploded;
136 Time b = Time::FromLocalExploded(exploded);
145 Time a = Time::Now();
146 Time::Exploded exploded;
149 Time b = Time::FromUTCExploded(exploded);
154 Time::Exploded exploded;
155 Time::Now().LocalMidnight().LocalExplode(&exploded);
164 time(&current_time);
177 Time parsed_time;
178 EXPECT_TRUE(Time::FromString(time_buf, &parsed_time));
183 Time time;
184 EXPECT_TRUE(Time::FromString("Sun, 06 May 2012 12:00:00 GMT", &time));
185 Time::Exploded exploded;
186 time.UTCExplode(&exploded);
191 Time time;
192 EXPECT_TRUE(Time::FromString("Wed, 09 May 2012 12:00:00 GMT", &time));
193 Time::Exploded exploded;
194 time.UTCExplode(&exploded);
199 Time time;
200 EXPECT_TRUE(Time::FromString("Sat, 12 May 2012 12:00:00 GMT", &time));
201 Time::Exploded exploded;
202 time.UTCExplode(&exploded);
207 Time parsed_time;
208 EXPECT_TRUE(Time::FromString("Mon, 15 Oct 2007 19:45:00 GMT", &parsed_time));
213 Time parsed_time;
214 EXPECT_TRUE(Time::FromString("15 Oct 07 12:45:00", &parsed_time));
219 Time parsed_time;
220 EXPECT_TRUE(Time::FromString("15 Oct 07 19:45 GMT", &parsed_time));
225 Time parsed_time;
226 EXPECT_TRUE(Time::FromString("Mon Oct 15 12:45 PDT 2007", &parsed_time));
231 Time parsed_time;
232 EXPECT_TRUE(Time::FromString("Monday, Oct 15, 2007 12:45 PM", &parsed_time));
237 Time parsed_time;
238 EXPECT_TRUE(Time::FromString("10/15/07 12:45:00 PM", &parsed_time));
243 Time parsed_time;
244 EXPECT_TRUE(Time::FromString("15-OCT-2007 12:45pm", &parsed_time));
249 Time parsed_time;
250 EXPECT_TRUE(Time::FromString("16 Oct 2007 4:45-JST (Tuesday)", &parsed_time));
255 Time parsed_time;
256 EXPECT_TRUE(Time::FromString("15/10/07 12:45", &parsed_time));
262 Time parsed_time;
265 EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:00 +0100 1970",
268 EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:00 GMT 1970",
274 Time parsed_time;
277 EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:01 +0100 1970",
280 EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:01 GMT 1970",
286 Time parsed_time;
289 EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:02 +0100 1970",
292 EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:02 GMT 1970",
298 Time parsed_time;
301 EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:59 +0100 1970",
304 EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 1969",
310 // cause timegm() to return -1. The parsed time should not be 1 second
313 Time parsed_time;
315 EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 2100",
321 Time parsed_time;
324 EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:58 +0100 1970",
327 EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:58 GMT 1969",
333 Time parsed_time;
336 EXPECT_TRUE(Time::FromString("Wed Jun 29 19:40:01 +0100 1960",
339 EXPECT_TRUE(Time::FromString("Wed Jun 29 18:40:01 GMT 1960",
342 EXPECT_TRUE(Time::FromString("Wed Jun 29 17:40:01 GMT 1960",
348 Time parsed_time;
349 EXPECT_FALSE(Time::FromString("", &parsed_time));
353 Time parsed_time;
354 EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time));
359 Time t;
360 Time::Exploded exploded;
362 t = Time::UnixEpoch() - TimeDelta::FromMicroseconds(1);
374 t = Time::UnixEpoch() - TimeDelta::FromMicroseconds(1000);
386 t = Time::UnixEpoch() - TimeDelta::FromMicroseconds(1001);
398 t = Time::UnixEpoch() - TimeDelta::FromMilliseconds(1000);
410 t = Time::UnixEpoch() - TimeDelta::FromMilliseconds(1001);
423 t = Time::UnixEpoch();
435 t = Time::UnixEpoch() + TimeDelta::FromMicroseconds(1);
447 t = Time::UnixEpoch() + TimeDelta::FromMicroseconds(1000);
459 t = Time::UnixEpoch() + TimeDelta::FromMilliseconds(1000);
471 t = Time::UnixEpoch() + TimeDelta::FromMilliseconds(1001);
485 Time max = Time::Max();
487 EXPECT_EQ(max, Time::Max());
488 EXPECT_GT(max, Time::Now());
489 EXPECT_GT(max, Time());
493 Time t = Time::Max();
496 t = Time::FromDoubleT(std::numeric_limits<double>::max());
500 t = Time::FromJsTime(std::numeric_limits<double>::max());
504 t = Time::FromTimeT(std::numeric_limits<time_t>::max());
511 tval.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
512 t = Time::FromTimeVal(tval);
516 EXPECT_EQ(static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1,
521 t = Time::FromCFAbsoluteTime(std::numeric_limits<CFAbsoluteTime>::max());
530 t = Time::FromFileTime(ftime);
540 Time t = Time::FromInternalValue(std::numeric_limits<int64>::max() - 1);
548 // This crashed inside Time:: FromLocalExploded() on Android 4.1.2.
550 Time::Exploded midnight = {2013, // year
563 Time t = Time::FromLocalExploded(midnight);
575 // time clock has a finer granularity than the Sleep()
578 // Time(ms timer) Time(us timer)
605 // of time -- less than 15ms. Unfortunately, if we happen to have a
620 // change, we detect the minimum time between measurements.
690 Time::kMicrosecondsPerSecond + 1).ToTimeSpec();
696 // Our internal time format is serialized in things like databases, so it's
700 Time::Exploded exploded;
709 Time t = Time::FromUTCExploded(exploded);
713 // We can't test 1601 epoch, since the system time functions on Linux