LCOV - code coverage report
Current view: top level - include/tools - datetime.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 18 29 62.1 %
Date: 2014-04-11 Functions: 10 14 71.4 %
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 INCLUDED_TOOLS_DATETIME_HXX
      20             : #define INCLUDED_TOOLS_DATETIME_HXX
      21             : 
      22             : #include <tools/toolsdllapi.h>
      23             : #include <tools/date.hxx>
      24             : #include <tools/time.hxx>
      25             : 
      26             : class TOOLS_DLLPUBLIC SAL_WARN_UNUSED DateTime : public Date, public Time
      27             : {
      28             : public:
      29             :     enum DateTimeInitSystem
      30             :     {
      31             :         SYSTEM
      32             :     };
      33             : 
      34             :     // TODO temporary until all uses are inspected and resolved
      35             :     enum DateTimeInitEmpty
      36             :     {
      37             :         EMPTY
      38             :     };
      39             : 
      40       36142 :                     DateTime( DateTimeInitEmpty ) : Date( Date::EMPTY ), Time( Time::EMPTY ) {}
      41        2382 :                     DateTime( DateTimeInitSystem ) : Date( Date::SYSTEM ), Time( Time::SYSTEM ) {}
      42        1186 :                     DateTime( const DateTime& rDateTime ) :
      43        1186 :                         Date( rDateTime ), Time( rDateTime ) {}
      44        1763 :                     DateTime( const Date& rDate ) : Date( rDate ), Time(0) {}
      45             :                     DateTime( const Time& rTime ) : Date(0), Time( rTime ) {}
      46        8568 :                     DateTime( const Date& rDate, const Time& rTime ) :
      47        8568 :                         Date( rDate ), Time( rTime ) {}
      48             : 
      49             :     bool            IsBetween( const DateTime& rFrom,
      50             :                                const DateTime& rTo ) const;
      51             : 
      52           0 :     bool            IsEqualIgnoreNanoSec( const DateTime& rDateTime ) const
      53             :                     {
      54           0 :                         if ( Date::operator!=( rDateTime ) )
      55           0 :                             return false;
      56           0 :                         return Time::IsEqualIgnoreNanoSec( rDateTime );
      57             :                     }
      58             : 
      59         945 :     bool            operator ==( const DateTime& rDateTime ) const
      60        1890 :                         { return (Date::operator==( rDateTime ) &&
      61        1890 :                                   Time::operator==( rDateTime )); }
      62           0 :     bool            operator !=( const DateTime& rDateTime ) const
      63           0 :                         { return (Date::operator!=( rDateTime ) ||
      64           0 :                                   Time::operator!=( rDateTime )); }
      65             :     bool            operator  >( const DateTime& rDateTime ) const;
      66             :     bool            operator  <( const DateTime& rDateTime ) const;
      67             :     bool            operator >=( const DateTime& rDateTime ) const;
      68             :     bool            operator <=( const DateTime& rDateTime ) const;
      69             : 
      70             :     long            GetSecFromDateTime( const Date& rDate ) const;
      71             : 
      72          42 :     void            ConvertToUTC()       { *this -= Time::GetUTCOffset(); }
      73         277 :     void            ConvertToLocalTime() { *this += Time::GetUTCOffset(); }
      74             : 
      75           1 :     DateTime&       operator +=( long nDays )
      76           1 :                         { Date::operator+=( nDays ); return *this; }
      77           0 :     DateTime&       operator -=( long nDays )
      78           0 :                         { Date::operator-=( nDays ); return *this; }
      79             :     DateTime&       operator +=( double fTimeInDays );
      80             :     DateTime&       operator -=( double fTimeInDays )
      81             :                         { return operator+=( -fTimeInDays ); }
      82             :     DateTime&       operator +=( const Time& rTime );
      83             :     DateTime&       operator -=( const Time& rTime );
      84             : 
      85             :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, long nDays );
      86             :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, long nDays );
      87             :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, double fTimeInDays );
      88             :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, double fTimeInDays )
      89             :                         { return operator+( rDateTime, -fTimeInDays ); }
      90             :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, const Time& rTime );
      91             :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, const Time& rTime );
      92             :     TOOLS_DLLPUBLIC friend double   operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 );
      93           0 :     TOOLS_DLLPUBLIC friend long     operator -( const DateTime& rDateTime, const Date& rDate )
      94           0 :                         { return (const Date&) rDateTime - rDate; }
      95             : 
      96             :     DateTime&       operator =( const DateTime& rDateTime );
      97             : 
      98             :     void            GetWin32FileDateTime( sal_uInt32 & rLower, sal_uInt32 & rUpper );
      99             :     static DateTime CreateFromWin32FileDateTime( const sal_uInt32 & rLower, const sal_uInt32 & rUpper );
     100             : };
     101             : 
     102         895 : inline DateTime& DateTime::operator =( const DateTime& rDateTime )
     103             : {
     104         895 :     Date::operator=( rDateTime );
     105         895 :     Time::operator=( rDateTime );
     106         895 :     return *this;
     107             : }
     108             : 
     109             : #endif
     110             : 
     111             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10