CTDateTime Class

class CTDateTime

Description

The CTDateTime class represents DateTime objects.

See Also

CTDateTimeDateTime, CTDateTime

Preconditions

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

 

CTDateTime Operators

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

 

CTDateTime::operator =

Syntax

CTDateTime& operator = (CTDATETIME DateTime)
CTDateTime& operator = (const  CTDateTime& DateTime)

Parameters

  • DateTime [in] The CTDateTime object or DateTime to be assigned to the new CTDateTime object

Description

These overloaded operators assign a DateTime or CTDateTime object to a CTDateTime object

Return

The new CTDateTime object

 

CTDateTime::operator <, <=, >, >=, ==, !=

Syntax

CTBOOL operator < (const CTDateTime& DateTime)
CTBOOL operator <= (const CTDateTime& DateTime)
CTBOOL operator > (const CTDateTime& DateTime)
CTBOOL operator >= (const CTDateTime& DateTime)
CTBOOL operator == (const CTDateTime& DateTime)
CTBOOL operator != (const CTDateTime& DateTime)

Parameters

  • DateTime [in] The DateTime to be compared to this CTDateTime object

Description

These overloaded operators make comparisons between the CTDateTime object and DateTime.

Return

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

 

CTDateTime Methods

Constructor / Destructor

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

DateTime Handling

  • GetDateTime(): Retrieves the DateTime.
  • SetDateTime(): Sets the DateTime to the CTDateTime object.
  • Pack(): Packs an hour, minute and second value into a CTDATETIME type value.
  • Unpack(): Unpacks a CTDATETIME type value into hour, minute and second values
  • GetDate(): Retrieves a CTDate object from a CTDateTime object.
  • GetTime(): Retrieves a CTTime object from a CTDateTime object.
  • Year(): Retrieves the year component of a CTDATETIME object.
  • Month(): Retrieves the month component of a CTDATETIME object.
  • Day(): Retrieves the day component of a CTDATETIME object.
  • DayOfWeek(): Retrieves the day of the week from the date part of the CTDATETIME object.
  • IsLeapYear(): Indicates if the year component from a CTDATETIME object is a leap year.
  • Hour(): Retrieves the hour component from a CTDATETIME type value
  • Minute(): Retrieves the minute component from a CTDATETIME type value
  • Second(): Retrieves the second component from a CTDATETIME type value
  • DateTimeToString(): Converts a packed CTDATETIME type value to a CTString object
  • StringToDateTime(): Converts a CTString object to a DateTime object
  • CurrentDateTime(): Retrieves the current system date and time.
  • CurrentDate(): Retrieve the current system date and sets the time to zeros

 

CTDateTime::CTDateTime

Syntax

CTDateTime( )
CTDateTime(NINT year, NINT month, NINT day, NINT hour = 0, NINT minute = 0, NINT second = 0)
CTDateTime(CTDATE Date, CTTIME Time = 0)
CTDateTime(const CTDate& Date, const CTTime& Time = 0)
CTDateTime(CTDATETIME DateTime)
CTDateTime(CTDateTime& DateTime)

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.
  • hour [in] The hour to set to the CTDateTime object.
  • minute [in] The minute to set to the CTDateTime object.
  • second [in] The second to set to the CTDateTime object.
  • Date [in] The date to set to the CTDateTime object
  • Time [in] The Time to set to the CTDateTime object
  • DateTime [in] The DateTime to set to the CTDateTime object

Description

This is the constructor for the CTDateTime object.

See also

~CTDateTime()

 

CTDateTime::~CTDateTime

Syntax

~CTDateTime

Parameters

This destructor has no parameters.

Description

This is the destructor for the CTDateTime object.

See also

CTDateTime()

 

CTDateTime::CurrentDate

Syntax

CTDate CurrentDate( )

Parameters

This method has no parameters.

Description

Retrieves the current system date and sets the time to zero

Return

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

See also

GetDate(), CurrentDateTime()

 

CTDateTime::CurrentDateTime

Syntax

CTDateTime CurrentDateTime( )

Parameters

This method has no parameters.

Description

Retrieves the current system date and time

Return

CurrentDateTime() returns a CTDateTime object with the system current DateTime.

See also

GetDateTime(), CurrentDate()

 

CTDateTime::DateTimeToString

Syntax

CTString DateTimeToString(CTDATE_TYPE DateType, CTTIME_TYPE TimeType) const

Parameters

  • DateType [in] The Date type format used to convert to string. The valid Date type formats are shown is "Data Types".
  • TimeType [in] The Time type format used to convert to string. The valid Time type formats are shown in "Data Types".

Description

Converts a packed CTDATETIME type value to a CTString object.

Return

DateTimeToString() returns a CTString object with the DateTime.

See also

StringToDateTime()

 

CTDateTime::Day

Syntax

NINT Day( ) const

Parameters

This method has no parameters.

Description

Retrieves the day component from a CTDATETIME object.

Return

Day() returns the unpacked day.

See also

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

 

CTDateTime::DayOfWeek

Syntax

NINT DayOfWeek( ) const

Parameters

This method has no parameters.

Description

Retrieves the day of the week from the date part of the CTDATETIME object. 0 is Sunday, 1 is Monday, ..., 6 is Saturday.

Return

DayOfWeek() returns the day of the week.

See also

Day()

 

CTDateTime::GetDate

Syntax

CTDATE GetDate( ) const

Parameters

This method has no parameters.

Description

Retrieves a CTDate object from a CTDateTime object.

Return

GetDate() returns a CTDATE object with the date.

See also

SetDate(), GetDateTime()

 

CTDateTime::GetDateTime

Syntax

CTDATETIME GetDateTime( ) const

Parameters

This method has no parameters.

Description

Retrieves the DateTime.

Return

GetDateTime() returns a CTDATETIME object with the DateTime.

See also

SetDateTime(), CurrentDateTime()

 

CTDateTime::GetTime

Syntax

CTTIME GetTime( ) const

Parameters

This method has no parameters.

Description

Retrieves a CTTime object from a CTDateTime object

Return

GetTime() returns a CTTIME object with the Time.

See also

SetTime(), GetDateTime()

 

CTDateTime::IsLeapYear

Syntax

CTBOOL IsLeapYear( ) const

Parameters

This method has no parameters.

Description

Indicates if the year component from a CTDateTime object is a leap year.

Return

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

See also

Year()

 

CTDateTime::Hour

Syntax

NINT Hour( ) const

Parameters

This method has no parameters.

Description

Retrieves the hour component from a CTDATETIME object.

Return

Hour() returns the unpacked hour.

See also

Minute(), Second(), Unpack(), Pack()

 

CTDateTime::Minute

Syntax

NINT Minute( ) const

Parameters

This method has no parameters.

Description

Retrieves the minute component from a CTDATETIME object

Return

Minute() returns the unpacked minute.

See also

Unpack(), Hour(), Second(), Pack()

 

CTDateTime::Month

Syntax

NINT Month( ) const

Parameters

This method has no parameters.

Description

Retrieves the month component from a CTDATETIME object

Return

Month() returns the unpacked month.

See also

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

 

CTDateTime::Pack

Syntax

void Pack(NINT year, NINT month, NINT day, NINT hour = 0,
          NINT minute = 0, NINT second = 0)

Parameters

  • year [in] The year to pack.
  • month [in] The month to pack.
  • day [in] The day to pack.
  • hour [in] The hour to pack.
  • minute [in] The minute to pack.
  • second [in] The second to pack.

Description

Packs an hour, minute and second value into a CTDATETIME object.

Return

None.

See also

Unpack()

 

CTDateTime::Second

Syntax

NINT Second( ) const

Parameters

This method has no parameters.

Description

Retrieves the second component from a CTDateTime object.

Return

Second() returns the unpacked second.

See also

Minute(), Hour(), SecondOfWeek(), Unpack(), Pack()

 

CTDateTime::SetDateTime

Syntax

void SetDateTime(CTDATETIME DateTime)
void SetDateTime(const CTDateTime& DateTime)
void SetDateTime (CTDATE Date, CTTIME Time = 0)
void SetDateTime(const CTDate& Date, const CTTime& Time = 0)

Parameters

  • DateTime [in] The new DateTime to set to the CTDateTime object.
  • Date [in] The new date to set to the CTDateTime object.
  • Time [in] The new time to set to the CTDateTime object.

Description

Sets the DateTime to the CTDateTime object.

Return

None.

See also

GetDateTime()

 

CTDateTime::StringToDateTime

Syntax

void StringToDateTime(const CTString& str, CTDATE_TYPE DateType,
                      CTTIME_TYPE TimeType)

Parameters

  • str [in] The string object to be converted.
  • DateType [in] The Date type format used to convert to string. The valid Date type formats are shown in "Data Types"
  • TimeType [in] The Time type format used to convert to string. The valid Time type formats are shown in "Data Types".

Description

Converts a CTString object to a DateTime object.

Return

None.

See also

DateTimeToString()

 

CTDateTime::Unpack

Syntax

void Unpack(NINT& year, NINT& month, NINT& day , NINT& hour,
            NINT& minute, NINT& second) const

Parameters

  • year [out] The unpacked year.
  • month [out] The unpacked month.
  • day [out] The unpacked day.
  • hour [out] The unpacked hour.
  • minute [out] The unpacked minute.
  • second [out] The unpacked second.

Description

Unpacks a CTDateTime type value into hour, minute and second values

Return

None.

See also

Pack(), Hour(), Minute(), Second(), DayOfWeek()

 

CTDateTime::Year

Syntax

NINT Year( ) const

Parameters

This method has no parameters.

Description

Retrieves the year component of a CTDateTime object.

Return

Year returns the unpacked year.

See also

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