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 class Date from Quantity
19 inherits Storable from Standard
21 ---Purpose: This class provides services to manage date information.
22 -- A date represents the following time intervals:
23 -- year, month, day, hour, minute, second,
24 -- millisecond and microsecond.
25 -- Current time is expressed in elapsed seconds
26 -- and microseconds beginning from 00:00 GMT,
27 -- January 1, 1979 (zero hour). The valid date can
28 -- only be later than this one.
29 -- Note: a Period object gives the interval between two dates.
35 raises DateDefinitionError from Quantity , OutOfRange from Standard
40 ---Purpose: Constructs a default date
41 -- (00:00 GMT, January 1, 1979 (zero hour)); use the function
42 -- SetValues to define the required date; or
44 Create ( mm, dd, yyyy, hh, mn, ss : Integer ; mis , mics : Integer = 0)
46 ---Purpose: Constructs a date from the year yyyy, the
47 -- month mm, the day dd, the hour hh, the minute
48 -- mn, the second ss, the millisecond mis
49 -- (defaulted to 0) and the microsecond mics (defaulted to 0)..
50 -- With: 1 <= mm <= 12
51 -- 1 <= dd <= max number of days of <mm>
59 -- Quantity_DateDefinitionError if mm, dd, hh,
60 -- mn, ss, mis and mics are not the components of the valid date.
61 raises DateDefinitionError;
63 Values (me ; mm, dd, yy, hh, mn, ss, mis, mics : out Integer) is static;
64 ---Purpose: Gets a complete Date.
65 -- - in mm - the month,
67 -- - in yyyy - the year,
68 -- - in hh - the hour,
69 -- - in mn - the minute,
70 -- - in ss - the second,
71 -- - in mis - the millisecond, and
72 -- - in mics - the microsecond
73 SetValues (me : out; mm, dd, yy, hh, mn, ss : Integer;
74 mis, mics : Integer = 0)
75 ---Purpose: Assigns to this date the year yyyy, the month
76 -- mm, the day dd, the hour hh, the minute mn, the
77 -- second ss, the millisecond mis (defaulted to 0)
78 -- and the microsecond mics (defaulted to 0).
80 -- Quantity_DateDefinitionError if mm, dd, hh,
81 -- mn, ss, mis and mics are not components of a valid date.
82 raises DateDefinitionError is static;
84 Difference (me : out; anOther : Date) returns Period is static;
85 ---Purpose: Subtracts one Date from another one to find the period
86 -- between and returns the value.
87 -- The result is the absolute value between the difference
90 Subtract (me : out; aPeriod : Period) returns Date
91 ---Purpose: Subtracts a period from a Date and returns the new Date.
92 -- Raises an exception if the result date is anterior to
94 ---C++: alias operator -
95 raises OutOfRange is static;
97 Add(me : out; aPeriod : Period) returns Date is static;
98 ---Purpose: Adds a Period to a Date and returns the new Date.
99 ---C++: alias operator +
101 Year (me : out) returns Integer is static;
102 ---Purpose: Returns year of a Date.
104 Month (me : out) returns Integer is static;
105 ---Purpose: Returns month of a Date.
107 Day (me : out) returns Integer is static;
108 ---Purpose: Returns Day of a Date.
110 Hour (me : out) returns Integer is static;
111 ---Purpose: Returns Hour of a Date.
113 Minute (me : out) returns Integer is static;
114 ---Purpose: Returns minute of a Date.
116 Second (me : out) returns Integer is static;
117 ---Purpose: Returns seconde of a Date.
119 MilliSecond (me : out) returns Integer is static;
120 ---Purpose: Returns millisecond of a Date.
122 MicroSecond (me : out) returns Integer is static;
123 ---Purpose: Returns microsecond of a Date.
125 IsEqual (me ; anOther : Date) returns Boolean is static;
126 ---Purpose: Returns TRUE if both <me> and <other> are equal.
127 -- This method is an alias of operator ==.
128 ---C++: alias operator ==
131 IsEarlier (me ; anOther : Date) returns Boolean is static;
132 ---Purpose: Returns TRUE if <me> is earlier than <other>.
133 ---C++: alias operator <
135 IsLater (me ; anOther : Date) returns Boolean is static;
136 ---Purpose: Returns TRUE if <me> is later then <other>.
137 ---C++: alias operator >
139 IsValid (myclass ; mm, dd, yy, hh, mn, ss : Integer;
140 mis, mics : Integer = 0) returns Boolean;
141 ---Purpose: Checks the validity of a date - returns true if a
142 -- date defined from the year yyyy, the month mm,
143 -- the day dd, the hour hh, the minute mn, the
144 -- second ss, the millisecond mis (defaulted to 0)
145 -- and the microsecond mics (defaulted to 0) is valid.
146 -- A date must satisfy the conditions above:
147 -- - yyyy is greater than or equal to 1979,
148 -- - mm lies within the range [1, 12] (with 1
149 -- corresponding to January and 12 to December),
150 -- - dd lies within a valid range for the month mm
151 -- (from 1 to 28, 29, 30 or 31 depending on
152 -- mm and whether yyyy is a leap year or not),
153 -- - hh lies within the range [0, 23],
154 -- - mn lies within the range [0, 59],
155 -- - ss lies within the range [0, 59],
156 -- - mis lies within the range [0, 999],
157 -- - mics lies within the range [0, 999].C
159 IsLeap (myclass ; yy : Integer ) returns Boolean;
160 ---Purpose: Returns true if a year is a leap year.
161 -- The leap years are divisable by 4 and not by 100 except
162 -- the years divisable by 400.
168 end Date from Quantity;