1 // Created on: 1993-01-04
2 // Created by: J.P. BOUDIER - J.P. TIRAULT
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Quantity_Period_HeaderFile
18 #define _Quantity_Period_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 class Quantity_PeriodDefinitionError;
28 //! Manages date intervals. For example, a Period object
29 //! gives the interval between two dates.
30 //! A period is expressed in seconds and microseconds.
44 Standard_EXPORT Quantity_Period(const Standard_Integer dd, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0);
46 //! Creates a Period with a number of seconds and microseconds.
48 //! Quantity_PeriodDefinitionError:
49 //! - if the number of seconds expressed either by:
50 //! - dd days, hh hours, mn minutes and ss seconds, or
53 //! - if the number of microseconds expressed either by:
54 //! - mis milliseconds and mics microseconds, or
57 Standard_EXPORT Quantity_Period(const Standard_Integer ss, const Standard_Integer mics = 0);
59 //! Decomposes this period into a number of days,hours,
60 //! minutes,seconds,milliseconds and microseconds
61 //! Example of return values:
62 //! 2 days, 15 hours, 0 minute , 0 second
63 //! 0 millisecond and 0 microsecond
64 Standard_EXPORT void Values (Standard_Integer& dd, Standard_Integer& hh, Standard_Integer& mn, Standard_Integer& ss, Standard_Integer& mis, Standard_Integer& mics) const;
66 //! Returns the number of seconds in Ss and the
67 //! number of remainding microseconds in Mics of this period.
68 //! Example of return values: 3600 seconds and 0 microseconds
69 Standard_EXPORT void Values (Standard_Integer& ss, Standard_Integer& mics) const;
71 //! Assigns to this period the time interval defined
72 //! - with dd days, hh hours, mn minutes, ss
73 //! seconds, mis (defaulted to 0) milliseconds and
74 //! mics (defaulted to 0) microseconds; or
75 Standard_EXPORT void SetValues (const Standard_Integer dd, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0);
77 //! Assigns to this period the time interval defined
78 //! - with Ss seconds and Mics (defaulted to 0) microseconds.
80 //! Quantity_PeriodDefinitionError:
81 //! - if the number of seconds expressed either by:
82 //! - dd days, hh hours, mn minutes and ss seconds, or
85 //! - if the number of microseconds expressed either by:
86 //! - mis milliseconds and mics microseconds, or
89 Standard_EXPORT void SetValues (const Standard_Integer ss, const Standard_Integer mics = 0);
91 //! Subtracts one Period from another and returns the difference.
92 Standard_EXPORT Quantity_Period Subtract (const Quantity_Period& anOther) const;
93 Quantity_Period operator - (const Quantity_Period& anOther) const
95 return Subtract(anOther);
98 //! Adds one Period to another one.
99 Standard_EXPORT Quantity_Period Add (const Quantity_Period& anOther) const;
100 Quantity_Period operator + (const Quantity_Period& anOther) const
105 //! Returns TRUE if both <me> and <other> are equal.
106 Standard_EXPORT Standard_Boolean IsEqual (const Quantity_Period& anOther) const;
107 Standard_Boolean operator == (const Quantity_Period& anOther) const
109 return IsEqual(anOther);
112 //! Returns TRUE if <me> is shorter than <other>.
113 Standard_EXPORT Standard_Boolean IsShorter (const Quantity_Period& anOther) const;
114 Standard_Boolean operator < (const Quantity_Period& anOther) const
116 return IsShorter(anOther);
119 //! Returns TRUE if <me> is longer then <other>.
120 Standard_EXPORT Standard_Boolean IsLonger (const Quantity_Period& anOther) const;
121 Standard_Boolean operator > (const Quantity_Period& anOther) const
123 return IsLonger(anOther);
126 //! Checks the validity of a Period in form (dd,hh,mn,ss,mil,mic)
133 Standard_EXPORT static Standard_Boolean IsValid (const Standard_Integer dd, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0);
135 //! Checks the validity of a Period in form (ss,mic)
138 Standard_EXPORT static Standard_Boolean IsValid (const Standard_Integer ss, const Standard_Integer mics = 0);
142 Standard_Integer mySec;
143 Standard_Integer myUSec;
147 #endif // _Quantity_Period_HeaderFile