update dev300-m58
[ooovba.git] / unotools / source / misc / datetime.cxx
blob9f1005d2ae9a84681710ab498155c9f2877373d2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datetime.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_unotools.hxx"
33 #include <unotools/datetime.hxx>
34 #include <tools/date.hxx>
35 #include <tools/time.hxx>
36 #include <tools/datetime.hxx>
38 //.........................................................................
39 namespace utl
41 //.........................................................................
43 //------------------------------------------------------------------
44 void typeConvert(const Time& _rTime, starutil::Time& _rOut)
46 _rOut.Hours = _rTime.GetHour();
47 _rOut.Minutes = _rTime.GetMin();
48 _rOut.Seconds = _rTime.GetSec();
49 _rOut.HundredthSeconds = _rTime.Get100Sec();
52 //------------------------------------------------------------------
53 void typeConvert(const starutil::Time& _rTime, Time& _rOut)
55 _rOut = Time(_rTime.Hours, _rTime.Minutes, _rTime.Seconds, _rTime.HundredthSeconds);
58 //------------------------------------------------------------------
59 void typeConvert(const Date& _rDate, starutil::Date& _rOut)
61 _rOut.Day = _rDate.GetDay();
62 _rOut.Month = _rDate.GetMonth();
63 _rOut.Year = _rDate.GetYear();
66 //------------------------------------------------------------------
67 void typeConvert(const starutil::Date& _rDate, Date& _rOut)
69 _rOut = Date(_rDate.Day, _rDate.Month, _rDate.Year);
72 //------------------------------------------------------------------
73 void typeConvert(const DateTime& _rDateTime, starutil::DateTime& _rOut)
75 _rOut.Year = _rDateTime.GetYear();
76 _rOut.Month = _rDateTime.GetMonth();
77 _rOut.Day = _rDateTime.GetDay();
78 _rOut.Hours = _rDateTime.GetHour();
79 _rOut.Minutes = _rDateTime.GetMin();
80 _rOut.Seconds = _rDateTime.GetSec();
81 _rOut.HundredthSeconds = _rDateTime.Get100Sec();
84 //------------------------------------------------------------------
85 void typeConvert(const starutil::DateTime& _rDateTime, DateTime& _rOut)
87 Date aDate(_rDateTime.Day, _rDateTime.Month, _rDateTime.Year);
88 Time aTime(_rDateTime.Hours, _rDateTime.Minutes, _rDateTime.Seconds, _rDateTime.HundredthSeconds);
89 _rOut = DateTime(aDate, aTime);
92 //-------------------------------------------------------------------------
93 sal_Bool operator ==(const starutil::DateTime& _rLeft, const starutil::DateTime& _rRight)
95 return ( _rLeft.HundredthSeconds == _rRight.HundredthSeconds) &&
96 ( _rLeft.Seconds == _rRight.Seconds) &&
97 ( _rLeft.Minutes == _rRight.Minutes) &&
98 ( _rLeft.Hours == _rRight.Hours) &&
99 ( _rLeft.Day == _rRight.Day) &&
100 ( _rLeft.Month == _rRight.Month) &&
101 ( _rLeft.Year == _rRight.Year) ;
104 //-------------------------------------------------------------------------
105 sal_Bool operator ==(const starutil::Date& _rLeft, const starutil::Date& _rRight)
107 return ( _rLeft.Day == _rRight.Day) &&
108 ( _rLeft.Month == _rRight.Month) &&
109 ( _rLeft.Year == _rRight.Year) ;
112 //-------------------------------------------------------------------------
113 sal_Bool operator ==(const starutil::Time& _rLeft, const starutil::Time& _rRight)
115 return ( _rLeft.HundredthSeconds == _rRight.HundredthSeconds) &&
116 ( _rLeft.Seconds == _rRight.Seconds) &&
117 ( _rLeft.Minutes == _rRight.Minutes) &&
118 ( _rLeft.Hours == _rRight.Hours) ;
121 //.........................................................................
122 } // namespace utl
123 //.........................................................................