LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/tools - datetime.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 29 55.2 %
Date: 2013-07-09 Functions: 9 14 64.3 %
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 _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 SAL_WARN_UNUSED 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       17968 :                     DateTime( DateTimeInitEmpty ) : Date( Date::EMPTY ), Time( Time::EMPTY ) {}
      42        1500 :                     DateTime( DateTimeInitSystem ) : Date( Date::SYSTEM ), Time( Time::SYSTEM ) {}
      43          94 :                     DateTime( const DateTime& rDateTime ) :
      44          94 :                         Date( rDateTime ), Time( rDateTime ) {}
      45         686 :                     DateTime( const Date& rDate ) : Date( rDate ), Time(0) {}
      46             :                     DateTime( const Time& rTime ) : Date(0), Time( rTime ) {}
      47        4704 :                     DateTime( const Date& rDate, const Time& rTime ) :
      48        4704 :                         Date( rDate ), Time( rTime ) {}
      49             : 
      50             :     bool            IsBetween( const DateTime& rFrom,
      51             :                                const DateTime& rTo ) const;
      52             : 
      53           0 :     bool            IsEqualIgnoreNanoSec( const DateTime& rDateTime ) const
      54             :                     {
      55           0 :                         if ( Date::operator!=( rDateTime ) )
      56           0 :                             return false;
      57           0 :                         return Time::IsEqualIgnoreNanoSec( rDateTime );
      58             :                     }
      59             : 
      60         169 :     bool            operator ==( const DateTime& rDateTime ) const
      61         338 :                         { return (Date::operator==( rDateTime ) &&
      62         338 :                                   Time::operator==( rDateTime )); }
      63           0 :     bool            operator !=( const DateTime& rDateTime ) const
      64           0 :                         { return (Date::operator!=( rDateTime ) ||
      65           0 :                                   Time::operator!=( rDateTime )); }
      66             :     bool            operator  >( const DateTime& rDateTime ) const;
      67             :     bool            operator  <( const DateTime& rDateTime ) const;
      68             :     bool            operator >=( const DateTime& rDateTime ) const;
      69             :     bool            operator <=( const DateTime& rDateTime ) const;
      70             : 
      71             :     long            GetSecFromDateTime( const Date& rDate ) const;
      72             : 
      73          20 :     void            ConvertToUTC()       { *this -= Time::GetUTCOffset(); }
      74         198 :     void            ConvertToLocalTime() { *this += Time::GetUTCOffset(); }
      75             : 
      76           0 :     DateTime&       operator +=( long nDays )
      77           0 :                         { Date::operator+=( nDays ); return *this; }
      78           0 :     DateTime&       operator -=( long nDays )
      79           0 :                         { 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          35 : inline DateTime& DateTime::operator =( const DateTime& rDateTime )
     104             : {
     105          35 :     Date::operator=( rDateTime );
     106          35 :     Time::operator=( rDateTime );
     107          35 :     return *this;
     108             : }
     109             : 
     110             : #endif
     111             : 
     112             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10