|
||||
File indexing completed on 2025-01-18 10:04:41
0001 // Created on: 1993-01-04 0002 // Created by: J.P. BOUDIER - J.P. TIRAULT 0003 // Copyright (c) 1993-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Quantity_Date_HeaderFile 0018 #define _Quantity_Date_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_Boolean.hxx> 0025 class Quantity_Period; 0026 0027 //! This class provides services to manage date information. 0028 //! A date represents the following time intervals: 0029 //! year, month, day, hour, minute, second, 0030 //! millisecond and microsecond. 0031 //! Current time is expressed in elapsed seconds 0032 //! and microseconds beginning from 00:00 GMT, 0033 //! January 1, 1979 (zero hour). The valid date can 0034 //! only be later than this one. 0035 //! Note: a Period object gives the interval between two dates. 0036 class Quantity_Date 0037 { 0038 public: 0039 0040 DEFINE_STANDARD_ALLOC 0041 0042 //! Constructs a default date 0043 //! (00:00 GMT, January 1, 1979 (zero hour)); use the function 0044 //! SetValues to define the required date; or 0045 Standard_EXPORT Quantity_Date(); 0046 0047 //! Constructs a date from the year yyyy, the 0048 //! month mm, the day dd, the hour hh, the minute 0049 //! mn, the second ss, the millisecond mis 0050 //! (defaulted to 0) and the microsecond mics (defaulted to 0).. 0051 //! With: 1 <= mm <= 12 0052 //! 1 <= dd <= max number of days of <mm> 0053 //! 1979 <= yyyy 0054 //! 0 <= hh <= 23 0055 //! 0 <= mn <= 59 0056 //! 0 <= ss <= 59 0057 //! 0 <= mis <= 999 0058 //! 0 <= mics <= 999 0059 //! Exceptions 0060 //! Quantity_DateDefinitionError if mm, dd, hh, 0061 //! mn, ss, mis and mics are not the components of the valid date. 0062 Standard_EXPORT Quantity_Date(const Standard_Integer mm, const Standard_Integer dd, const Standard_Integer yyyy, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0); 0063 0064 //! Gets a complete Date. 0065 //! - in mm - the month, 0066 //! - in dd - the day, 0067 //! - in yyyy - the year, 0068 //! - in hh - the hour, 0069 //! - in mn - the minute, 0070 //! - in ss - the second, 0071 //! - in mis - the millisecond, and 0072 //! - in mics - the microsecond 0073 Standard_EXPORT void Values (Standard_Integer& mm, Standard_Integer& dd, Standard_Integer& yy, Standard_Integer& hh, Standard_Integer& mn, Standard_Integer& ss, Standard_Integer& mis, Standard_Integer& mics) const; 0074 0075 //! Assigns to this date the year yyyy, the month 0076 //! mm, the day dd, the hour hh, the minute mn, the 0077 //! second ss, the millisecond mis (defaulted to 0) 0078 //! and the microsecond mics (defaulted to 0). 0079 //! Exceptions 0080 //! Quantity_DateDefinitionError if mm, dd, hh, 0081 //! mn, ss, mis and mics are not components of a valid date. 0082 Standard_EXPORT void SetValues (const Standard_Integer mm, const Standard_Integer dd, const Standard_Integer yy, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0); 0083 0084 //! Subtracts one Date from another one to find the period 0085 //! between and returns the value. 0086 //! The result is the absolute value between the difference 0087 //! of two dates. 0088 Standard_EXPORT Quantity_Period Difference (const Quantity_Date& anOther); 0089 0090 //! Subtracts a period from a Date and returns the new Date. 0091 //! Raises an exception if the result date is anterior to 0092 //! Jan 1, 1979. 0093 Standard_EXPORT Quantity_Date Subtract (const Quantity_Period& aPeriod); 0094 Quantity_Date operator - (const Quantity_Period& aPeriod) 0095 { 0096 return Subtract(aPeriod); 0097 } 0098 0099 //! Adds a Period to a Date and returns the new Date. 0100 Standard_EXPORT Quantity_Date Add (const Quantity_Period& aPeriod); 0101 Quantity_Date operator + (const Quantity_Period& aPeriod) 0102 { 0103 return Add(aPeriod); 0104 } 0105 0106 //! Returns year of a Date. 0107 Standard_EXPORT Standard_Integer Year(); 0108 0109 //! Returns month of a Date. 0110 Standard_EXPORT Standard_Integer Month(); 0111 0112 //! Returns Day of a Date. 0113 Standard_EXPORT Standard_Integer Day(); 0114 0115 //! Returns Hour of a Date. 0116 Standard_EXPORT Standard_Integer Hour(); 0117 0118 //! Returns minute of a Date. 0119 Standard_EXPORT Standard_Integer Minute(); 0120 0121 //! Returns seconde of a Date. 0122 Standard_EXPORT Standard_Integer Second(); 0123 0124 //! Returns millisecond of a Date. 0125 Standard_EXPORT Standard_Integer MilliSecond(); 0126 0127 //! Returns microsecond of a Date. 0128 Standard_EXPORT Standard_Integer MicroSecond(); 0129 0130 //! Returns TRUE if both <me> and <other> are equal. 0131 //! This method is an alias of operator ==. 0132 Standard_EXPORT Standard_Boolean IsEqual (const Quantity_Date& anOther) const; 0133 Standard_Boolean operator == (const Quantity_Date& anOther) const 0134 { 0135 return IsEqual(anOther); 0136 } 0137 0138 //! Returns TRUE if <me> is earlier than <other>. 0139 Standard_EXPORT Standard_Boolean IsEarlier (const Quantity_Date& anOther) const; 0140 Standard_Boolean operator < (const Quantity_Date& anOther) const 0141 { 0142 return IsEarlier(anOther); 0143 } 0144 0145 //! Returns TRUE if <me> is later then <other>. 0146 Standard_EXPORT Standard_Boolean IsLater (const Quantity_Date& anOther) const; 0147 Standard_Boolean operator > (const Quantity_Date& anOther) const 0148 { 0149 return IsLater(anOther); 0150 } 0151 0152 //! Checks the validity of a date - returns true if a 0153 //! date defined from the year yyyy, the month mm, 0154 //! the day dd, the hour hh, the minute mn, the 0155 //! second ss, the millisecond mis (defaulted to 0) 0156 //! and the microsecond mics (defaulted to 0) is valid. 0157 //! A date must satisfy the conditions above: 0158 //! - yyyy is greater than or equal to 1979, 0159 //! - mm lies within the range [1, 12] (with 1 0160 //! corresponding to January and 12 to December), 0161 //! - dd lies within a valid range for the month mm 0162 //! (from 1 to 28, 29, 30 or 31 depending on 0163 //! mm and whether yyyy is a leap year or not), 0164 //! - hh lies within the range [0, 23], 0165 //! - mn lies within the range [0, 59], 0166 //! - ss lies within the range [0, 59], 0167 //! - mis lies within the range [0, 999], 0168 //! - mics lies within the range [0, 999].C 0169 Standard_EXPORT static Standard_Boolean IsValid (const Standard_Integer mm, const Standard_Integer dd, const Standard_Integer yy, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0); 0170 0171 //! Returns true if a year is a leap year. 0172 //! The leap years are divisible by 4 and not by 100 except 0173 //! the years divisible by 400. 0174 static Standard_Boolean IsLeap (const Standard_Integer yy) 0175 { 0176 return ((yy % 4 == 0) && (yy % 100 != 0)) 0177 || (yy % 400) == 0; 0178 } 0179 0180 private: 0181 0182 Standard_Integer mySec; 0183 Standard_Integer myUSec; 0184 0185 }; 0186 0187 #endif // _Quantity_Date_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |