CTDate Class

class CTDate

Description

The CTDate class represents Date objects.

See Also

CTDateTime(), CTTime()

Preconditions

This is one of the basic objects from the c-tree database layer.

 

CTDate Operators

  • operator = : Assignment operator
  • operator <, <=, >, >=, ==, != : Comparison operators

 

CTDate::operator =

Syntax

CTDate& operator = (const CTDate& Date)
CTDate& operator = (const CTDATE Date)

Parameters

  • Date [in] The CTDate object or date to be assigned to the new CTDate object

Description

These overloaded operators assign a date or CTDate object to a CTDate object

Return

The new CTDate object

 

CTDate::operator <, <=, >, >=, ==, !=

Syntax

CTBOOL operator < (const CTDate& Date)
CTBOOL operator <= (const CTDate& Date)
CTBOOL operator > (const CTDate& Date)
CTBOOL operator >= (const CTDate& Date)
CTBOOL operator == (const CTDate& Date)
CTBOOL operator != (const CTDate& Date)

Parameters

  • Date [in] The date to be compared to this CTDate object

Description

These overloaded operators make comparisons between the CTDate object and Date.

Return

The operators return YES or NO, depending on the result of the comparison.

 

CTDate Methods

Constructor / Destructor

  • CTDate(): Creates a CTDate object
  • ~CTDate(): Destroys a CTDate Object and resets all the dependent objects

Date Handling

  • GetDate(): Retrieves the date.
  • SetDate(): Sets the date to the CTDate object.
  • Pack(): Packs a year, month and day value into a CTDATE type value.
  • Unpack(): Unpacks a CTDATE type value into a year, month and day values
  • Year(): Retrieves the year component of a packed CTDATE type value
  • Month(): Retrieves the month component of a packed CTDATE type value
  • Day(): Retrieves the day component of a packed CTDATE type value
  • DayOfWeek(): Retrieves the day of the week from a packed CTDATE type value.
  • IsLeapYear(): Indicates if the year component of a packed CTDATE type value is a leap year
  • DateToString(): Converts a packed CTDATE type value to a CTString object
  • StringToDate(): Converts a CTString object to a date object
  • CurrentDate(): Retrieves the current system date.

 

CTDate::CTDate

Syntax

CTDate( )
CTDate(NINT year, NINT month, NINT day)
CTDate(CTDATE Date)
CTDate(const CTDate& Date)

Parameters

  • year [in] The year to set to the CTDate object.
  • month [in] The month to set to the CTDate object.
  • day [in] The day to set to the CTDate object.
  • Date [in] The date to set to the CTDate object

Description

This is the constructor for the CTDate object.

See also

~CTDate()

 

CTDate::~CTDate

Syntax

~CTDate

Parameters

This destructor has no parameters.

Description

This is the destructor for the CTDate object.

See also

CTDate()

 

CTDate::CurrentDate

Syntax

CTDate CurrentDate( )

Parameters

This method has no parameters.

Description

Retrieves the current system date

Return

CurrentDate() returns a CTDate object with the system current date.

See also

GetDate()

 

CTDate::DateToString

Syntax

CTString DateToString(CTDATE_TYPE DateType) const

Parameters

  • DateType [in] The date type format used to convert to string. The valid date type formats are:
Symbolic Constant Explanation
CTDATE_DEF Use default date type
CTDATE_MDCY Date is mm/dd/ccyy
CTDATE_MDY Date is mm/dd/yy
CTDATE_DMCY Date is dd/mm/ccyy
CTDATE_DMY Date is dd/mm/yy
CTDATE_CYMD Date is ccyymmdd
CTDATE_YMD Date is yymmdd

Description

Converts a packed CTDATE type value to a CTString object.

Return

DateToString() returns a CTString object with the date.

See also

StringToDate()

 

CTDate::Day

Syntax

NINT Day( ) const

Parameters

This method has no parameters.

Description

Retrieves the day component of a packed CTDATE type value.

Return

Day returns the unpacked day.

See also

Month(), Year(), DayOfWeek(), Unpack(), Pack()

 

CTDate::DayOfWeek

Syntax

NINT DayOfWeek( ) const

Parameters

This method has no parameters.

Description

Retrieves the day of the week from a packed CTDATE type value. 0 is Sunday, 1 is Monday, ..., 6 is Saturday.

Return

DayOfWeek() returns the day of the week.

See also

Day()

 

CTDate::GetDate

Syntax

CTDATE GetDate( ) const

Parameters

This method has no parameters.

Description

Retrieves the date.

Return

GetDate() returns a CTDATE object with the date.

See also

SetDate(), CurrentDate()

 

CTDate::IsLeapYear

Syntax

CTBOOL IsLeapYear( ) const

Parameters

This method has no parameters.

Description

Indicates if the year component of a packed CTDATE type value is a leap year.

Return

IsLeapYear() returns YES if the packed year is a leap year, and NO otherwise.

See also

Year()

 

CTDate::Month

Syntax

NINT Month( ) const

Parameters

This method has no parameters.

Description

Retrieves the month component of a packed CTDATE type value

Return

Month() returns the unpacked month.

See also

Unpack(), Year(), Day(), Pack()

 

CTDate::Pack

Syntax

void Pack(NINT year, NINT month, NINT day)

Parameters

  • year [in] The year to pack.
  • month [in] The month to pack.
  • day [in] The day to pack.

Description

Packs a year, month and day value into a CTDATE type value.

Return

None.

See also

Unpack()

 

CTDate::SetDate

Syntax

void SetDate(CTDATE Date)
void SetDate(const CTDate& Date)

Parameters

  • Date [in] The new date to set to the CTDate object.

Description

Sets the date to the CTDate object.

Return

None.

See also

GetDate()

 

CTDate::StringToDate

Syntax

void StringToDate(const CTString& str, CTDATE_TYPE DateType)

Parameters

  • str [in] The string object to be converted.
  • DateType [in] The date type format to be used in the conversion. Valid date formats are shown in "Data Types".

Description

Converts a CTString object to a date object.

Return

None.

See also

DateToString()

 

CTDate::Unpack

Syntax

void Unpack(NINT& year, NINT& month, NINT& day) const

Parameters

  • year [out] The unpacked year.
  • month [out] The unpacked month.
  • day [out] The unpacked day.

Description

Unpacks a CTDATE type value into a year, month and day values

Return

None.

See also

Pack(), Year(), Month(), Day(), DayOfWeek()

 

CTDate::Year

Syntax

NINT Year( ) const

Parameters

This method has no parameters.

Description

Retrieves the year component of a packed CTDATE type value.

Return

Year() returns the unpacked year.

See also

Month(), Day(), Unpack(), Pack()