Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
Quantity_Date Class Reference

This class provides services to manage date information. A date represents the following time intervals: year, month, day, hour, minute, second, millisecond and microsecond. Current time is expressed in elapsed seconds and microseconds beginning from 00:00 GMT, January 1, 1979 (zero hour). The valid date can only be later than this one. Note: a Period object gives the interval between two dates. More...

#include <Quantity_Date.hxx>

Public Member Functions

 Quantity_Date ()
 Constructs a default date (00:00 GMT, January 1, 1979 (zero hour)); use the function SetValues to define the required date; or.
 
 Quantity_Date (const int mm, const int dd, const int yyyy, const int hh, const int mn, const int ss, const int mis=0, const int mics=0)
 Constructs a date from the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0). With: 1 <= mm <= 12 1 <= dd <= max number of days of <mm> 1979 <= yyyy 0 <= hh <= 23 0 <= mn <= 59 0 <= ss <= 59 0 <= mis <= 999 0 <= mics <= 999 Exceptions Quantity_DateDefinitionError if mm, dd, hh, mn, ss, mis and mics are not the components of the valid date.
 
void Values (int &mm, int &dd, int &yy, int &hh, int &mn, int &ss, int &mis, int &mics) const
 Gets a complete Date.
 
void SetValues (const int mm, const int dd, const int yy, const int hh, const int mn, const int ss, const int mis=0, const int mics=0)
 Assigns to this date the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0). Exceptions Quantity_DateDefinitionError if mm, dd, hh, mn, ss, mis and mics are not components of a valid date.
 
Quantity_Period Difference (const Quantity_Date &anOther)
 Subtracts one Date from another one to find the period between and returns the value. The result is the absolute value between the difference of two dates.
 
Quantity_Date Subtract (const Quantity_Period &aPeriod)
 Subtracts a period from a Date and returns the new Date. Raises an exception if the result date is anterior to Jan 1, 1979.
 
Quantity_Date operator- (const Quantity_Period &aPeriod)
 
Quantity_Date Add (const Quantity_Period &aPeriod)
 Adds a Period to a Date and returns the new Date.
 
Quantity_Date operator+ (const Quantity_Period &aPeriod)
 
int Year ()
 Returns year of a Date.
 
int Month ()
 Returns month of a Date.
 
int Day ()
 Returns Day of a Date.
 
int Hour ()
 Returns Hour of a Date.
 
int Minute ()
 Returns minute of a Date.
 
int Second ()
 Returns second of a Date.
 
int MilliSecond ()
 Returns millisecond of a Date.
 
int MicroSecond ()
 Returns microsecond of a Date.
 
constexpr bool IsEqual (const Quantity_Date &anOther) const noexcept
 Returns TRUE if both <me> and <other> are equal. This method is an alias of operator ==.
 
constexpr bool operator== (const Quantity_Date &anOther) const noexcept
 
constexpr bool IsEarlier (const Quantity_Date &anOther) const noexcept
 Returns TRUE if <me> is earlier than <other>.
 
constexpr bool operator< (const Quantity_Date &anOther) const noexcept
 
constexpr bool IsLater (const Quantity_Date &anOther) const noexcept
 Returns TRUE if <me> is later then <other>.
 
constexpr bool operator> (const Quantity_Date &anOther) const noexcept
 

Static Public Member Functions

static bool IsValid (const int mm, const int dd, const int yy, const int hh, const int mn, const int ss, const int mis=0, const int mics=0)
 Checks the validity of a date - returns true if a date defined from the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0) is valid. A date must satisfy the conditions above:
 
static constexpr bool IsLeap (const int yy) noexcept
 Returns true if a year is a leap year. The leap years are divisible by 4 and not by 100 except the years divisible by 400.
 

Detailed Description

This class provides services to manage date information. A date represents the following time intervals: year, month, day, hour, minute, second, millisecond and microsecond. Current time is expressed in elapsed seconds and microseconds beginning from 00:00 GMT, January 1, 1979 (zero hour). The valid date can only be later than this one. Note: a Period object gives the interval between two dates.

Constructor & Destructor Documentation

◆ Quantity_Date() [1/2]

Quantity_Date::Quantity_Date ( )

Constructs a default date (00:00 GMT, January 1, 1979 (zero hour)); use the function SetValues to define the required date; or.

◆ Quantity_Date() [2/2]

Quantity_Date::Quantity_Date ( const int mm,
const int dd,
const int yyyy,
const int hh,
const int mn,
const int ss,
const int mis = 0,
const int mics = 0 )

Constructs a date from the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0). With: 1 <= mm <= 12 1 <= dd <= max number of days of <mm> 1979 <= yyyy 0 <= hh <= 23 0 <= mn <= 59 0 <= ss <= 59 0 <= mis <= 999 0 <= mics <= 999 Exceptions Quantity_DateDefinitionError if mm, dd, hh, mn, ss, mis and mics are not the components of the valid date.

Member Function Documentation

◆ Add()

Quantity_Date Quantity_Date::Add ( const Quantity_Period & aPeriod)

Adds a Period to a Date and returns the new Date.

◆ Day()

int Quantity_Date::Day ( )

Returns Day of a Date.

◆ Difference()

Quantity_Period Quantity_Date::Difference ( const Quantity_Date & anOther)

Subtracts one Date from another one to find the period between and returns the value. The result is the absolute value between the difference of two dates.

◆ Hour()

int Quantity_Date::Hour ( )

Returns Hour of a Date.

◆ IsEarlier()

constexpr bool Quantity_Date::IsEarlier ( const Quantity_Date & anOther) const
inlineconstexprnoexcept

Returns TRUE if <me> is earlier than <other>.

◆ IsEqual()

constexpr bool Quantity_Date::IsEqual ( const Quantity_Date & anOther) const
inlineconstexprnoexcept

Returns TRUE if both <me> and <other> are equal. This method is an alias of operator ==.

◆ IsLater()

constexpr bool Quantity_Date::IsLater ( const Quantity_Date & anOther) const
inlineconstexprnoexcept

Returns TRUE if <me> is later then <other>.

◆ IsLeap()

static constexpr bool Quantity_Date::IsLeap ( const int yy)
inlinestaticconstexprnoexcept

Returns true if a year is a leap year. The leap years are divisible by 4 and not by 100 except the years divisible by 400.

◆ IsValid()

static bool Quantity_Date::IsValid ( const int mm,
const int dd,
const int yy,
const int hh,
const int mn,
const int ss,
const int mis = 0,
const int mics = 0 )
static

Checks the validity of a date - returns true if a date defined from the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0) is valid. A date must satisfy the conditions above:

  • yyyy is greater than or equal to 1979,
  • mm lies within the range [1, 12] (with 1 corresponding to January and 12 to December),
  • dd lies within a valid range for the month mm (from 1 to 28, 29, 30 or 31 depending on mm and whether yyyy is a leap year or not),
  • hh lies within the range [0, 23],
  • mn lies within the range [0, 59],
  • ss lies within the range [0, 59],
  • mis lies within the range [0, 999],
  • mics lies within the range [0, 999].C

◆ MicroSecond()

int Quantity_Date::MicroSecond ( )

Returns microsecond of a Date.

◆ MilliSecond()

int Quantity_Date::MilliSecond ( )

Returns millisecond of a Date.

◆ Minute()

int Quantity_Date::Minute ( )

Returns minute of a Date.

◆ Month()

int Quantity_Date::Month ( )

Returns month of a Date.

◆ operator+()

Quantity_Date Quantity_Date::operator+ ( const Quantity_Period & aPeriod)
inline

◆ operator-()

Quantity_Date Quantity_Date::operator- ( const Quantity_Period & aPeriod)
inline

◆ operator<()

constexpr bool Quantity_Date::operator< ( const Quantity_Date & anOther) const
inlineconstexprnoexcept

◆ operator==()

constexpr bool Quantity_Date::operator== ( const Quantity_Date & anOther) const
inlineconstexprnoexcept

◆ operator>()

constexpr bool Quantity_Date::operator> ( const Quantity_Date & anOther) const
inlineconstexprnoexcept

◆ Second()

int Quantity_Date::Second ( )

Returns second of a Date.

◆ SetValues()

void Quantity_Date::SetValues ( const int mm,
const int dd,
const int yy,
const int hh,
const int mn,
const int ss,
const int mis = 0,
const int mics = 0 )

Assigns to this date the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0). Exceptions Quantity_DateDefinitionError if mm, dd, hh, mn, ss, mis and mics are not components of a valid date.

◆ Subtract()

Quantity_Date Quantity_Date::Subtract ( const Quantity_Period & aPeriod)

Subtracts a period from a Date and returns the new Date. Raises an exception if the result date is anterior to Jan 1, 1979.

◆ Values()

void Quantity_Date::Values ( int & mm,
int & dd,
int & yy,
int & hh,
int & mn,
int & ss,
int & mis,
int & mics ) const

Gets a complete Date.

  • in mm - the month,
  • in dd - the day,
  • in yyyy - the year,
  • in hh - the hour,
  • in mn - the minute,
  • in ss - the second,
  • in mis - the millisecond, and
  • in mics - the microsecond

◆ Year()

int Quantity_Date::Year ( )

Returns year of a Date.


The documentation for this class was generated from the following file: