LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/tools - datetime.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 27 59.3 %
Date: 2012-08-25 Functions: 9 13 69.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 14 28.6 %

           Branch data     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 _DATETIME_HXX
      20                 :            : #define _DATETIME_HXX
      21                 :            : 
      22                 :            : #include "tools/toolsdllapi.h"
      23                 :            : #include <tools/solar.h>
      24                 :            : #include <tools/date.hxx>
      25                 :            : #include <tools/time.hxx>
      26                 :            : 
      27                 :            : class TOOLS_DLLPUBLIC DateTime : public Date, public Time
      28                 :            : {
      29                 :            : public:
      30                 :            :     enum DateTimeInitSystem
      31                 :            :     {
      32                 :            :         SYSTEM
      33                 :            :     };
      34                 :            : 
      35                 :            :     // TODO temporary until all uses are inspected and resolved
      36                 :            :     enum DateTimeInitEmpty
      37                 :            :     {
      38                 :            :         EMPTY
      39                 :            :     };
      40                 :            : 
      41                 :      29066 :                     DateTime( DateTimeInitEmpty ) : Date( Date::EMPTY ), Time( Time::EMPTY ) {}
      42                 :       3517 :                     DateTime( DateTimeInitSystem ) : Date( Date::SYSTEM ), Time( Time::SYSTEM ) {}
      43                 :        150 :                     DateTime( const DateTime& rDateTime ) :
      44                 :        150 :                         Date( rDateTime ), Time( rDateTime ) {}
      45                 :        912 :                     DateTime( const Date& rDate ) : Date( rDate ), Time(0) {}
      46                 :            :                     DateTime( const Time& rTime ) : Date(0), Time( rTime ) {}
      47                 :       5987 :                     DateTime( const Date& rDate, const Time& rTime ) :
      48                 :       5987 :                         Date( rDate ), Time( rTime ) {}
      49                 :            : 
      50                 :            :     sal_Bool        IsBetween( const DateTime& rFrom,
      51                 :            :                                const DateTime& rTo ) const;
      52                 :            : 
      53                 :          0 :     sal_Bool        IsEqualIgnore100Sec( const DateTime& rDateTime ) const
      54                 :            :                     {
      55         [ #  # ]:          0 :                         if ( Date::operator!=( rDateTime ) )
      56                 :          0 :                             return sal_False;
      57                 :          0 :                         return Time::IsEqualIgnore100Sec( rDateTime );
      58                 :            :                     }
      59                 :            : 
      60                 :        437 :     sal_Bool        operator ==( const DateTime& rDateTime ) const
      61                 :        437 :                         { return (Date::operator==( rDateTime ) &&
      62 [ +  - ][ +  - ]:        437 :                                   Time::operator==( rDateTime )); }
      63                 :          0 :     sal_Bool        operator !=( const DateTime& rDateTime ) const
      64                 :          0 :                         { return (Date::operator!=( rDateTime ) ||
      65 [ #  # ][ #  # ]:          0 :                                   Time::operator!=( rDateTime )); }
      66                 :            :     sal_Bool        operator  >( const DateTime& rDateTime ) const;
      67                 :            :     sal_Bool        operator  <( const DateTime& rDateTime ) const;
      68                 :            :     sal_Bool        operator >=( const DateTime& rDateTime ) const;
      69                 :            :     sal_Bool        operator <=( const DateTime& rDateTime ) const;
      70                 :            : 
      71                 :            :     long            GetSecFromDateTime( const Date& rDate ) const;
      72                 :            : 
      73         [ +  - ]:         21 :     void            ConvertToUTC()       { *this -= Time::GetUTCOffset(); }
      74         [ +  - ]:        302 :     void            ConvertToLocalTime() { *this += Time::GetUTCOffset(); }
      75                 :            : 
      76                 :          0 :     DateTime&       operator +=( long nDays )
      77                 :          0 :                         { Date::operator+=( nDays ); return *this; }
      78                 :            :     DateTime&       operator -=( long nDays )
      79                 :            :                         { Date::operator-=( nDays ); return *this; }
      80                 :            :     DateTime&       operator +=( double fTimeInDays );
      81                 :            :     DateTime&       operator -=( double fTimeInDays )
      82                 :            :                         { return operator+=( -fTimeInDays ); }
      83                 :            :     DateTime&       operator +=( const Time& rTime );
      84                 :            :     DateTime&       operator -=( const Time& rTime );
      85                 :            : 
      86                 :            :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, long nDays );
      87                 :            :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, long nDays );
      88                 :            :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, double fTimeInDays );
      89                 :            :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, double fTimeInDays )
      90                 :            :                         { return operator+( rDateTime, -fTimeInDays ); }
      91                 :            :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, const Time& rTime );
      92                 :            :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, const Time& rTime );
      93                 :            :     TOOLS_DLLPUBLIC friend double   operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 );
      94                 :          0 :     TOOLS_DLLPUBLIC friend long     operator -( const DateTime& rDateTime, const Date& rDate )
      95                 :          0 :                         { return (const Date&) rDateTime - rDate; }
      96                 :            : 
      97                 :            :     DateTime&       operator =( const DateTime& rDateTime );
      98                 :            : 
      99                 :            :     void            GetWin32FileDateTime( sal_uInt32 & rLower, sal_uInt32 & rUpper );
     100                 :            :     static DateTime CreateFromWin32FileDateTime( const sal_uInt32 & rLower, const sal_uInt32 & rUpper );
     101                 :            : };
     102                 :            : 
     103                 :         36 : inline DateTime& DateTime::operator =( const DateTime& rDateTime )
     104                 :            : {
     105                 :         36 :     Date::operator=( rDateTime );
     106                 :         36 :     Time::operator=( rDateTime );
     107                 :         36 :     return *this;
     108                 :            : }
     109                 :            : 
     110                 :            : #endif
     111                 :            : 
     112                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10