LCOV - code coverage report
Current view: top level - include/tools - datetime.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 32 75.0 %
Date: 2015-06-13 12:38:46 Functions: 12 15 80.0 %
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             : #include <com/sun/star/util/DateTime.hpp>
      26             : 
      27             : class TOOLS_DLLPUBLIC SAL_WARN_UNUSED DateTime : public Date, public tools::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       51310 :                     DateTime( DateTimeInitEmpty ) : Date( Date::EMPTY ), Time( Time::EMPTY ) {}
      42        8421 :                     DateTime( DateTimeInitSystem ) : Date( Date::SYSTEM ), Time( Time::SYSTEM ) {}
      43        2489 :                     DateTime( const DateTime& rDateTime ) :
      44        2489 :                         Date( rDateTime ), Time( rDateTime ) {}
      45        3652 :                     DateTime( const Date& rDate ) : Date( rDate ), Time(0) {}
      46             :                     DateTime( const tools::Time& rTime ) : Date(0), Time( rTime ) {}
      47       15848 :                     DateTime( const Date& rDate, const tools::Time& rTime ) :
      48       15848 :                         Date( rDate ), Time( rTime ) {}
      49             :                     DateTime( const css::util::DateTime& rDateTime );
      50             : 
      51             :     css::util::DateTime
      52         762 :                     GetUNODateTime() const
      53        3048 :                         { return css::util::DateTime(GetNanoSec(), GetSec(), GetMin(), GetHour(),
      54        3810 :                               GetDay(), GetMonth(), GetYear(), false); }
      55             : 
      56             :     bool            IsBetween( const DateTime& rFrom,
      57             :                                const DateTime& rTo ) const;
      58             : 
      59           0 :     bool            IsEqualIgnoreNanoSec( const DateTime& rDateTime ) const
      60             :                     {
      61           0 :                         if ( Date::operator!=( rDateTime ) )
      62           0 :                             return false;
      63           0 :                         return Time::IsEqualIgnoreNanoSec( rDateTime );
      64             :                     }
      65             : 
      66        1776 :     bool            operator ==( const DateTime& rDateTime ) const
      67        3552 :                         { return (Date::operator==( rDateTime ) &&
      68        3552 :                                   Time::operator==( rDateTime )); }
      69          24 :     bool            operator !=( const DateTime& rDateTime ) const
      70          48 :                         { return (Date::operator!=( rDateTime ) ||
      71          48 :                                   Time::operator!=( rDateTime )); }
      72             :     bool            operator  >( const DateTime& rDateTime ) const;
      73             :     bool            operator  <( const DateTime& rDateTime ) const;
      74             :     bool            operator >=( const DateTime& rDateTime ) const;
      75             :     bool            operator <=( const DateTime& rDateTime ) const;
      76             : 
      77             :     long            GetSecFromDateTime( const Date& rDate ) const;
      78             : 
      79         166 :     void            ConvertToUTC()       { *this -= Time::GetUTCOffset(); }
      80         444 :     void            ConvertToLocalTime() { *this += Time::GetUTCOffset(); }
      81             : 
      82           7 :     DateTime&       operator +=( long nDays )
      83           7 :                         { Date::operator+=( nDays ); return *this; }
      84           0 :     DateTime&       operator -=( long nDays )
      85           0 :                         { Date::operator-=( nDays ); return *this; }
      86             :     DateTime&       operator +=( double fTimeInDays );
      87             :     DateTime&       operator -=( double fTimeInDays )
      88             :                         { return operator+=( -fTimeInDays ); }
      89             :     DateTime&       operator +=( const tools::Time& rTime );
      90             :     DateTime&       operator -=( const tools::Time& rTime );
      91             : 
      92             :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, long nDays );
      93             :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, long nDays );
      94             :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, double fTimeInDays );
      95             :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, double fTimeInDays )
      96             :                         { return operator+( rDateTime, -fTimeInDays ); }
      97             :     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, const tools::Time& rTime );
      98             :     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, const tools::Time& rTime );
      99             :     TOOLS_DLLPUBLIC friend double   operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 );
     100           0 :     TOOLS_DLLPUBLIC friend long     operator -( const DateTime& rDateTime, const Date& rDate )
     101           0 :                         { return (const Date&) rDateTime - rDate; }
     102             : 
     103             :     DateTime&       operator =( const DateTime& rDateTime );
     104             : 
     105             :     void            GetWin32FileDateTime( sal_uInt32 & rLower, sal_uInt32 & rUpper );
     106             :     static DateTime CreateFromWin32FileDateTime( const sal_uInt32 & rLower, const sal_uInt32 & rUpper );
     107             : };
     108             : 
     109        1746 : inline DateTime& DateTime::operator =( const DateTime& rDateTime )
     110             : {
     111        1746 :     Date::operator=( rDateTime );
     112        1746 :     Time::operator=( rDateTime );
     113        1746 :     return *this;
     114             : }
     115             : 
     116             : #endif
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11