1*8b851043SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*8b851043SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*8b851043SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*8b851043SAndrew Rist * distributed with this work for additional information
6*8b851043SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*8b851043SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*8b851043SAndrew Rist * "License"); you may not use this file except in compliance
9*8b851043SAndrew Rist * with the License. You may obtain a copy of the License at
10*8b851043SAndrew Rist *
11*8b851043SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*8b851043SAndrew Rist *
13*8b851043SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*8b851043SAndrew Rist * software distributed under the License is distributed on an
15*8b851043SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*8b851043SAndrew Rist * KIND, either express or implied. See the License for the
17*8b851043SAndrew Rist * specific language governing permissions and limitations
18*8b851043SAndrew Rist * under the License.
19*8b851043SAndrew Rist *
20*8b851043SAndrew Rist *************************************************************/
21*8b851043SAndrew Rist
22*8b851043SAndrew Rist
23cdf0e10cSrcweir #ifndef _DATETIME_HXX
24cdf0e10cSrcweir #define _DATETIME_HXX
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "tools/toolsdllapi.h"
27cdf0e10cSrcweir #include <tools/solar.h>
28cdf0e10cSrcweir #include <tools/date.hxx>
29cdf0e10cSrcweir #include <tools/time.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir // ------------
32cdf0e10cSrcweir // - DateTime -
33cdf0e10cSrcweir // ------------
34cdf0e10cSrcweir
35cdf0e10cSrcweir class TOOLS_DLLPUBLIC DateTime : public Date, public Time
36cdf0e10cSrcweir {
37cdf0e10cSrcweir public:
DateTime()38cdf0e10cSrcweir DateTime() : Date(), Time() {}
DateTime(const DateTime & rDateTime)39cdf0e10cSrcweir DateTime( const DateTime& rDateTime ) :
40cdf0e10cSrcweir Date( rDateTime ), Time( rDateTime ) {}
DateTime(const Date & rDate)41cdf0e10cSrcweir DateTime( const Date& rDate ) : Date( rDate ), Time(0) {}
DateTime(const Time & rTime)42cdf0e10cSrcweir DateTime( const Time& rTime ) : Date(0), Time( rTime ) {}
DateTime(const Date & rDate,const Time & rTime)43cdf0e10cSrcweir DateTime( const Date& rDate, const Time& rTime ) :
44cdf0e10cSrcweir Date( rDate ), Time( rTime ) {}
45cdf0e10cSrcweir
46cdf0e10cSrcweir sal_Bool IsBetween( const DateTime& rFrom,
47cdf0e10cSrcweir const DateTime& rTo ) const;
48cdf0e10cSrcweir
IsEqualIgnore100Sec(const DateTime & rDateTime) const49cdf0e10cSrcweir sal_Bool IsEqualIgnore100Sec( const DateTime& rDateTime ) const
50cdf0e10cSrcweir {
51cdf0e10cSrcweir if ( Date::operator!=( rDateTime ) )
52cdf0e10cSrcweir return sal_False;
53cdf0e10cSrcweir return Time::IsEqualIgnore100Sec( rDateTime );
54cdf0e10cSrcweir }
55cdf0e10cSrcweir
operator ==(const DateTime & rDateTime) const56cdf0e10cSrcweir sal_Bool operator ==( const DateTime& rDateTime ) const
57cdf0e10cSrcweir { return (Date::operator==( rDateTime ) &&
58cdf0e10cSrcweir Time::operator==( rDateTime )); }
operator !=(const DateTime & rDateTime) const59cdf0e10cSrcweir sal_Bool operator !=( const DateTime& rDateTime ) const
60cdf0e10cSrcweir { return (Date::operator!=( rDateTime ) ||
61cdf0e10cSrcweir Time::operator!=( rDateTime )); }
62cdf0e10cSrcweir sal_Bool operator >( const DateTime& rDateTime ) const;
63cdf0e10cSrcweir sal_Bool operator <( const DateTime& rDateTime ) const;
64cdf0e10cSrcweir sal_Bool operator >=( const DateTime& rDateTime ) const;
65cdf0e10cSrcweir sal_Bool operator <=( const DateTime& rDateTime ) const;
66cdf0e10cSrcweir
67cdf0e10cSrcweir long GetSecFromDateTime( const Date& rDate ) const;
68cdf0e10cSrcweir void MakeDateTimeFromSec( const Date& rDate, sal_uIntPtr nSec );
69cdf0e10cSrcweir
ConvertToUTC()70cdf0e10cSrcweir void ConvertToUTC() { *this -= Time::GetUTCOffset(); }
ConvertToLocalTime()71cdf0e10cSrcweir void ConvertToLocalTime() { *this += Time::GetUTCOffset(); }
72cdf0e10cSrcweir
operator +=(long nDays)73cdf0e10cSrcweir DateTime& operator +=( long nDays )
74cdf0e10cSrcweir { Date::operator+=( nDays ); return *this; }
operator -=(long nDays)75cdf0e10cSrcweir DateTime& operator -=( long nDays )
76cdf0e10cSrcweir { Date::operator-=( nDays ); return *this; }
77cdf0e10cSrcweir DateTime& operator +=( double fTimeInDays );
operator -=(double fTimeInDays)78cdf0e10cSrcweir DateTime& operator -=( double fTimeInDays )
79cdf0e10cSrcweir { return operator+=( -fTimeInDays ); }
80cdf0e10cSrcweir DateTime& operator +=( const Time& rTime );
81cdf0e10cSrcweir DateTime& operator -=( const Time& rTime );
82cdf0e10cSrcweir
83cdf0e10cSrcweir TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, long nDays );
84cdf0e10cSrcweir TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, long nDays );
85cdf0e10cSrcweir TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, double fTimeInDays );
operator -(const DateTime & rDateTime,double fTimeInDays)86cdf0e10cSrcweir TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, double fTimeInDays )
87cdf0e10cSrcweir { return operator+( rDateTime, -fTimeInDays ); }
88cdf0e10cSrcweir TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, const Time& rTime );
89cdf0e10cSrcweir TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, const Time& rTime );
90cdf0e10cSrcweir TOOLS_DLLPUBLIC friend double operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 );
operator -(const DateTime & rDateTime,const Date & rDate)91cdf0e10cSrcweir TOOLS_DLLPUBLIC friend long operator -( const DateTime& rDateTime, const Date& rDate )
92cdf0e10cSrcweir { return (const Date&) rDateTime - rDate; }
93cdf0e10cSrcweir
94cdf0e10cSrcweir DateTime& operator =( const DateTime& rDateTime );
95cdf0e10cSrcweir
96cdf0e10cSrcweir void GetWin32FileDateTime( sal_uInt32 & rLower, sal_uInt32 & rUpper );
97cdf0e10cSrcweir static DateTime CreateFromWin32FileDateTime( const sal_uInt32 & rLower, const sal_uInt32 & rUpper );
98cdf0e10cSrcweir };
99cdf0e10cSrcweir
operator =(const DateTime & rDateTime)100cdf0e10cSrcweir inline DateTime& DateTime::operator =( const DateTime& rDateTime )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir Date::operator=( rDateTime );
103cdf0e10cSrcweir Time::operator=( rDateTime );
104cdf0e10cSrcweir return *this;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir #endif // _DATETIME_HXX
108