LCOV - app.info - ipc/chromium/src/base/time.cc

LCOV - code coverage report
| Current view: | directory - ipc/chromium/src/base - time.cc (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 49 | 0 | 0.0 %
| Date: | 2012-04-21 | Functions: | 14 | 0 | 0.0 %

           1                 : // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
           2                 : // Use of this source code is governed by a BSD-style license that can be
           3                 : // found in the LICENSE file.
           4                 :
           5                 : #include "base/time.h"
           6                 : #include "base/string_util.h"
           7                 : #include "base/sys_string_conversions.h"
           8                 : #include "base/third_party/nspr/prtime.h"
           9                 :
          10                 : #include "base/logging.h"
          11                 :
          12                 : using namespace nspr;
          13                 :
          14                 : namespace base {
          15                 :
          16                 : // TimeDelta ------------------------------------------------------------------
          17                 :
          18               0 : int TimeDelta::InDays() const {
          19               0 :   return static_cast<int>(delta_ / Time::kMicrosecondsPerDay);
          20                 : }
          21                 :
          22               0 : int TimeDelta::InHours() const {
          23               0 :   return static_cast<int>(delta_ / Time::kMicrosecondsPerHour);
          24                 : }
          25                 :
          26               0 : int TimeDelta::InMinutes() const {
          27               0 :   return static_cast<int>(delta_ / Time::kMicrosecondsPerMinute);
          28                 : }
          29                 :
          30               0 : double TimeDelta::InSecondsF() const {
          31               0 :   return static_cast<double>(delta_) / Time::kMicrosecondsPerSecond;
          32                 : }
          33                 :
          34               0 : int64 TimeDelta::InSeconds() const {
          35               0 :   return delta_ / Time::kMicrosecondsPerSecond;
          36                 : }
          37                 :
          38               0 : double TimeDelta::InMillisecondsF() const {
          39               0 :   return static_cast<double>(delta_) / Time::kMicrosecondsPerMillisecond;
          40                 : }
          41                 :
          42               0 : int64 TimeDelta::InMilliseconds() const {
          43               0 :   return delta_ / Time::kMicrosecondsPerMillisecond;
          44                 : }
          45                 :
          46               0 : int64 TimeDelta::InMicroseconds() const {
          47               0 :   return delta_;
          48                 : }
          49                 :
          50                 : // Time -----------------------------------------------------------------------
          51                 :
          52                 : // static
          53               0 : Time Time::FromTimeT(time_t tt) {
          54               0 :   if (tt == 0)
          55               0 :     return Time();  // Preserve 0 so we can tell it doesn't exist.
          56               0 :   return (tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset;
          57                 : }
          58                 :
          59               0 : time_t Time::ToTimeT() const {
          60               0 :   if (us_ == 0)
          61               0 :     return 0;  // Preserve 0 so we can tell it doesn't exist.
          62               0 :   return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond;
          63                 : }
          64                 :
          65                 : // static
          66               0 : Time Time::FromDoubleT(double dt) {
          67                 :   return (dt * static_cast<double>(kMicrosecondsPerSecond)) +
          68               0 :       kTimeTToMicrosecondsOffset;
          69                 : }
          70                 :
          71               0 : double Time::ToDoubleT() const {
          72               0 :   if (us_ == 0)
          73               0 :     return 0;  // Preserve 0 so we can tell it doesn't exist.
          74                 :   return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) /
          75               0 :           static_cast<double>(kMicrosecondsPerSecond));
          76                 : }
          77                 :
          78               0 : Time Time::LocalMidnight() const {
          79                 :   Exploded exploded;
          80               0 :   LocalExplode(&exploded);
          81               0 :   exploded.hour = 0;
          82               0 :   exploded.minute = 0;
          83               0 :   exploded.second = 0;
          84               0 :   exploded.millisecond = 0;
          85               0 :   return FromLocalExploded(exploded);
          86                 : }
          87                 :
          88                 : // static
          89               0 : bool Time::FromString(const wchar_t* time_string, Time* parsed_time) {
          90               0 :   DCHECK((time_string != NULL) && (parsed_time != NULL));
          91               0 :   std::string ascii_time_string = SysWideToUTF8(time_string);
          92               0 :   if (ascii_time_string.length() == 0)
          93               0 :     return false;
          94               0 :   PRTime result_time = 0;
          95                 :   PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE,
          96               0 :                                        &result_time);
          97               0 :   if (PR_SUCCESS != result)
          98               0 :     return false;
          99               0 :   result_time += kTimeTToMicrosecondsOffset;
         100               0 :   *parsed_time = Time(result_time);
         101               0 :   return true;
         102                 : }
         103                 :
         104                 : }  // namespace base

Generated by: LCOV version 1.7