LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/tools - time.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 27 74.1 %
Date: 2012-12-27 Functions: 9 13 69.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef _TOOLS_TIME_HXX
      20             : #define _TOOLS_TIME_HXX
      21             : 
      22             : #include "tools/toolsdllapi.h"
      23             : #include <tools/solar.h>
      24             : 
      25             : class ResId;
      26             : 
      27             : /**
      28             :  @WARNING: This class can serve both as call clock time and time duration, and
      29             :            the mixing of these concepts leads to problems such as there being
      30             :            25 hours or 10 minus 20 seconds being (non-negative) 10 seconds.
      31             : */
      32             : 
      33             : class TOOLS_DLLPUBLIC SAL_WARN_UNUSED Time
      34             : {
      35             : private:
      36             :     sal_Int32       nTime;
      37             : 
      38             : public:
      39             :     enum TimeInitSystem
      40             :     {
      41             :         SYSTEM
      42             :     };
      43             : 
      44             :     // temporary until all uses are inspected and resolved
      45             :     enum TimeInitEmpty
      46             :     {
      47             :         EMPTY
      48             :     };
      49             : 
      50        7677 :                     Time( TimeInitEmpty )
      51        7677 :                         { nTime = 0; }
      52             :                     Time( TimeInitSystem );
      53             :                     Time( const ResId & rResId );
      54         439 :                     Time( sal_Int32 _nTime ) { Time::nTime = _nTime; }
      55             :                     Time( const Time& rTime );
      56             :                     Time( sal_uIntPtr nHour, sal_uIntPtr nMin,
      57             :                           sal_uIntPtr nSec = 0, sal_uIntPtr n100Sec = 0 );
      58             : 
      59           0 :     void            SetTime( sal_Int32 nNewTime ) { nTime = nNewTime; }
      60          33 :     sal_Int32       GetTime() const { return nTime; }
      61             : 
      62             :     void            SetHour( sal_uInt16 nNewHour );
      63             :     void            SetMin( sal_uInt16 nNewMin );
      64             :     void            SetSec( sal_uInt16 nNewSec );
      65             :     void            Set100Sec( sal_uInt16 nNew100Sec );
      66         221 :     sal_uInt16      GetHour() const
      67         221 :                     { sal_uIntPtr nTempTime = (nTime >= 0) ? nTime : nTime*-1;
      68         221 :                       return (sal_uInt16)(nTempTime / 1000000); }
      69         221 :     sal_uInt16      GetMin() const
      70         221 :                     { sal_uIntPtr nTempTime = (nTime >= 0) ? nTime : nTime*-1;
      71         221 :                       return (sal_uInt16)((nTempTime / 10000) % 100); }
      72         208 :     sal_uInt16      GetSec() const
      73         208 :                     { sal_uIntPtr nTempTime = (nTime >= 0) ? nTime : nTime*-1;
      74         208 :                       return (sal_uInt16)((nTempTime / 100) % 100); }
      75         194 :     sal_uInt16      Get100Sec() const
      76         194 :                     { sal_uIntPtr nTempTime = (nTime >= 0) ? nTime : nTime*-1;
      77         194 :                       return (sal_uInt16)(nTempTime % 100); }
      78             : 
      79             :     sal_Int32       GetMSFromTime() const;
      80             :     void            MakeTimeFromMS( sal_Int32 nMS );
      81             : 
      82             :                     /// 12 hours == 0.5 days
      83             :     double          GetTimeInDays() const;
      84             : 
      85             :     sal_Bool        IsBetween( const Time& rFrom, const Time& rTo ) const
      86             :                     { return ((nTime >= rFrom.nTime) && (nTime <= rTo.nTime)); }
      87             : 
      88             :     sal_Bool        IsEqualIgnore100Sec( const Time& rTime ) const;
      89             : 
      90         155 :     sal_Bool        operator ==( const Time& rTime ) const
      91         155 :                     { return (nTime == rTime.nTime); }
      92           6 :     sal_Bool        operator !=( const Time& rTime ) const
      93           6 :                     { return (nTime != rTime.nTime); }
      94           0 :     sal_Bool        operator  >( const Time& rTime ) const
      95           0 :                     { return (nTime > rTime.nTime); }
      96           0 :     sal_Bool        operator  <( const Time& rTime ) const
      97           0 :                     { return (nTime < rTime.nTime); }
      98             :     sal_Bool        operator >=( const Time& rTime ) const
      99             :                     { return (nTime >= rTime.nTime); }
     100             :     sal_Bool        operator <=( const Time& rTime ) const
     101             :                     { return (nTime <= rTime.nTime); }
     102             : 
     103             :     static Time     GetUTCOffset();
     104             :     static sal_uIntPtr  GetSystemTicks();       // Elapsed time
     105             : 
     106             :     void            ConvertToUTC()       { *this -= Time::GetUTCOffset(); }
     107             :     void            ConvertToLocalTime() { *this += Time::GetUTCOffset(); }
     108             : 
     109             :     Time&           operator =( const Time& rTime );
     110           0 :     Time            operator -() const
     111           0 :                         { return Time( nTime * -1 ); }
     112             :     Time&           operator +=( const Time& rTime );
     113             :     Time&           operator -=( const Time& rTime );
     114             :     TOOLS_DLLPUBLIC friend Time     operator +( const Time& rTime1, const Time& rTime2 );
     115             :     TOOLS_DLLPUBLIC friend Time     operator -( const Time& rTime1, const Time& rTime2 );
     116             : };
     117             : 
     118             : #endif
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10