Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_Date Class Reference

A class for dealing with dates. More...

Inheritance diagram for CP_Date:

CP_Object CP_NoCopy List of all members.

Public Member Functions

void SetID (FourCharCode inIdentifier)
FourCharCode GetID ()
void RegisterSignal (const CP_SignalHolder &inSignal)
CP_DataValueSignalFindSignal (const CP_String &inSignalName)
UInt32 GetNumberSignals ()
CP_String GetNthSignalName (UInt32 inSignalIndex)
void RegisterSlot (const CP_SlotHolder &inSlot)
CP_DataValueSlot FindSlot (const CP_String &inSlotName)
UInt32 GetNumberSlots ()
CP_String GetNthSlotName (UInt32 inSlotIndex)
template<class R, class P1, class P2>
CP_CommandHandlerSignalConnect (CPLAT::CP_CommandNo cmd, void(R::*handler)(P1, P2), SInt32 mode)
template<class R, class P1, class P2>
void Connect (CP_Object *control, const CPLAT::CP_String &signalName, void(R::*handler)(P1, P2))
Constructor / Destructor
 CP_Date ()
 Constructor.
 CP_Date (const CP_Date &inDate)
 CP_Date (UInt32 inJulianDate)
 CP_Date (const CP_String &inDateString, CP_E_DateFormat inDateFormat=CP_E_FullDateFormat, CP_E_DateFormatInput inDateFormatIn=CP_E_MMDDYYYY_DateFormat)
 CP_Date (UInt32 inMacSeconds, bool inMacOSTime)
 CP_Date (LongDateRec inDateRec)
 ~CP_Date ()
 Destructor.
Getters
UInt32 GetJulian ()
SInt16 GetYear ()
SInt16 GetMonth ()
SInt16 GetDay ()
SInt16 GetDayOfWeek ()
CP_String GetMonthString (bool inShortVersion=false)
void GetDate (LongDateRec &inDateRec)
Math
CP_Date operator+ (const SInt32 inDays)
CP_Date operator- (const SInt32 inDays)
UInt32 operator- (CP_Date &inDate)
CP_Dateoperator+= (const SInt32 inDays)
CP_Dateoperator-= (const SInt32 inDays)
CP_Dateoperator++ ()
CP_Dateoperator-- ()
const CP_Dateoperator= (const CP_Date &inDate)
const CP_Dateoperator= (const CP_String &inDateString)
bool operator> (const CP_Date &inDate)
bool operator> (const CP_String &inDateString)
bool operator< (const CP_Date &inDate)
bool operator< (const CP_String &inDateString)
bool operator>= (const CP_Date &inDate)
bool operator>= (const CP_String &inDateString)
bool operator<= (const CP_Date &inDate)
bool operator<= (const CP_String &inDateString)
bool operator== (const CP_Date &inDate)
bool operator== (const CP_String &inDateString)
bool operator!= (const CP_Date &inDate)
bool operator!= (const CP_String &inDateString)
const CP_DateAddMonths (SInt16 inMonths)
const CP_DateSubtractMonths (SInt16 inMonths)
const CP_DateAddYears (SInt16 inYears)
const CP_DateSubtractYears (SInt16 inYears)
const CP_DateAddDays (SInt16 inDays)
const CP_DateSubtractDays (SInt16 inDays)
SInt16 YearsOld ()
SInt16 ElapsedDays (CP_Date &inStartDate)
Format
CP_String Format (SInt16 inFormat=CP_DefaultDateFormat) const
Setters
void SetToSystemDate ()
void SetYear (SInt16 inYear)
void SetMonth (SInt16 inMonth)
void SetDay (SInt16 inDay)
void SetDayOfWeek (SInt16 inDayOfWeek)
void SetDate (LongDateRec inDateRec)
Testers
bool IsValid ()
parsing
bool ParseDateString (const CP_String &inDate, SInt16 &inMonth, SInt16 &inDay, SInt16 &inYear)

Static Public Member Functions

static void Connect (CP_Object *sender, const CP_String &signalName, CP_Object *receiver, const CP_String &slotName, const bool reciprocal=false)
static void Connect (CP_Object *sender, CP_Object *receiver, const bool reciprocal=false, const CP_String &signalName=kCP_Signal_ValueChanged, const CP_String &slotName=kCP_Slot_SetValue)

Protected Attributes

SInt16 fYear
SInt16 fMonth
SInt16 fDay
SInt16 fDayOfWeek
UInt32 fJulian
CP_E_DateFormat fCurrentDateFormat
CP_E_DateFormatInput fInputDateFormat
CP_Signals_ArrayfSignals
CP_Slots_ArrayfSlots
FourCharCode fObjectID

Static Protected Attributes

static FourCharCode fObjectIDCount = 0

Private Member Functions

Utility
void MDYToJulian ()
void JulianToWday ()
void JulianToMDY ()
void AdjustDays ()
bool ParseDateString (const CP_String &inDate)

Detailed Description

The CP_Date class provides methods for performing math on dates. Returning a specific part of the date, such as year, month, day.

There are also methods to return the date in a specific formatted way.


Constructor & Destructor Documentation

CP_Date::CP_Date  ) 
 

Constructor. Sets the date to todays date.

Exceptions:
none 

CP_Date::CP_Date const CP_Date inDate  ) 
 

Copy constructor.

Parameters:
inDate The date to copy the fields from.
Exceptions:
none 

CP_Date::CP_Date UInt32  inJulianDate  ) 
 

Constructor.

Parameters:
inJulianDate A UInt32 representing the date in Julian format.
Exceptions:
none 

CP_Date::CP_Date const CP_String inDateString,
CP_E_DateFormat  inDateFormat = CP_E_FullDateFormat,
CP_E_DateFormatInput  inDateFormatIn = CP_E_MMDDYYYY_DateFormat
 

Constructor.

Parameters:
inDateString A CP_String containing our date information.
inDateFormat Desired output formatting to use for date.
inDateFormatIn How is the input inDateString formatted.
Exceptions:
none 

CP_Date::CP_Date UInt32  inMacSeconds,
bool  inMacOSTime
 

Constructor. Constructs the date from the passed in MacOS seconds time.

Parameters:
inMacSeconds MacOS seconds count of the date.
inMacOSTime Flag to indicate the time is a MacOS seconds time and not a Julian time.
Exceptions:
none 

CP_Date::CP_Date LongDateRec  inDateRec  ) 
 

Constructor. Constructs the date from the passed in MacOS LongDateRec.

Parameters:
inDateRec MacOS LongDateRec containing the date.
Exceptions:
none 

CP_Date::~CP_Date  ) 
 

Destructor.

Exceptions:
none 


Member Function Documentation

UInt32 CP_Date::GetJulian  ) 
 

Returns the date in Julian format.

Exceptions:
none 
Returns:
UInt32 The date in Julian format.

SInt16 CP_Date::GetYear  ) 
 

Returns the year of the date.

Exceptions:
none 
Returns:
UInt16 The year portion of the date.

SInt16 CP_Date::GetMonth  ) 
 

Returns the month of the date.

Exceptions:
none 
Returns:
UInt16 The month portion of the date.

SInt16 CP_Date::GetDay  ) 
 

Returns the date of the date.

Exceptions:
none 
Returns:
UInt16 The day portion of the date.

SInt16 CP_Date::GetDayOfWeek  ) 
 

Returns the date of the week this date falls on.

Exceptions:
none 
Returns:
UInt16 The date of the week of this date.

CP_String CP_Date::GetMonthString bool  inShortVersion = false  ) 
 

Returns the month of the date in either a long or short version.

Parameters:
inShortVersion If true, then the short version of the month is returned.
Exceptions:
none 
Returns:
CP_String The month for this date.

void CP_Date::GetDate LongDateRec &  inOutDateRec  ) 
 

Returns the date in the passed in MacOS LongDateRec.

Parameters:
inOutDateRec Location to return the date in.
Exceptions:
none 

CP_Date CP_Date::operator+ const SInt32  inDays  ) 
 

Adds the passed in number of days to this date, and returns a new CP_Date object containing the new date.

Parameters:
inDays Number of days to add to this date.
Exceptions:
none 
Returns:
CP_Date New date with days added.

CP_Date CP_Date::operator- const SInt32  inDays  ) 
 

Subtracts the passed in number of days to this date, and returns a new CP_Date object containing the new date.

Parameters:
inDays Number of days to subtract from this date.
Exceptions:
none 
Returns:
CP_Date New date with days subtracted.

UInt32 CP_Date::operator- CP_Date inDate  ) 
 

Subtract the passed in date from this one, and return the result as a Julian formatted date.

Parameters:
inDate The date to subtract.
Exceptions:
none 
Returns:
SInt32 The Julian formatted date after the subtraction.

CP_Date & CP_Date::operator+= const SInt32  inDays  ) 
 

Adds the passed in number of days to this date.

Parameters:
inDays The number of days to add to this date.
Exceptions:
none 
Returns:
CP_Date Returns a reference to ourselves.

CP_Date & CP_Date::operator-= const SInt32  inDays  ) 
 

Subtracts the passed in number of days from this date.

Parameters:
inDays The number of days to subtract from this date.
Exceptions:
none 
Returns:
CP_Date Returns a reference to ourselves.

CP_Date & CP_Date::operator++  ) 
 

Increments the date by one day.

Exceptions:
none 
Returns:
CP_Date Returns a reference to ourselves.

CP_Date & CP_Date::operator--  ) 
 

Decrements the date by one day.

Exceptions:
none 
Returns:
CP_Date Returns a reference to ourselves.

const CP_Date & CP_Date::operator= const CP_Date inDate  ) 
 

Assignment operator. Copies the information from the passed in date

Parameters:
inDate The date to set the fields from.
Exceptions:
none 
Returns:
CP_Date const Returns a reference to ourselves.

const CP_Date & CP_Date::operator= const CP_String inDateString  ) 
 

Assignment operator. This version takes a CP_String containing a formatted date and will attempt to convert to the proper date format.

Parameters:
inDateString A CP_String object containing a date string.
Exceptions:
none 
Returns:
CP_Date const Returns a reference to ourselves.

bool CP_Date::operator> const CP_Date inDate  ) 
 

Greater than operator. Returns true if the passed in date represents a date this is greater than this date.

Parameters:
inDate The date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date greater than this objects date. Also returns false if the date is not valid.

bool CP_Date::operator> const CP_String inDateString  ) 
 

Greater than operator. Returns true if the passed in date string represents a date this is greater than this date. The passed in string is first converted to a CP_Date object before comparison. The format of the string must be properly formatted. See operator = for some examples.

Parameters:
inDateString A string representing the date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date greater than this objects date. Also returns false if the date is not valid.

bool CP_Date::operator< const CP_Date inDate  ) 
 

Less than operator. Returns true if the passed in date represents a date this is less than this date.

Parameters:
inDate The date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date less than this objects date. Also returns false if the date is not valid.

bool CP_Date::operator< const CP_String inDateString  ) 
 

Less than operator. Returns true if the passed in date string represents a date this is less than this date. The passed in string is first converted to a CP_Date object before comparison. The format of the string must be properly formatted. See operator = for some examples.

Parameters:
inDateString A string representing the date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date less than this objects date. Also returns false if the date is not valid.

bool CP_Date::operator>= const CP_Date inDate  ) 
 

Greater than or equal to operator. Returns true if the passed in date represents a date this is greater than or equal to this date.

Parameters:
inDate The date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date greater than or equal to this objects date. Also returns false if the date is not valid.

bool CP_Date::operator>= const CP_String inDateString  ) 
 

Greater than or equal to operator. Returns true if the passed in date string represents a date this is greater than or equal to this date. The passed in string is first converted to a CP_Date object before comparison. The format of the string must be properly formatted. See operator = for some examples.

Parameters:
inDateString A string representing the date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date greater than or equal to this objects date. Also returns false if the date is not valid.

bool CP_Date::operator<= const CP_Date inDate  ) 
 

Less than or equal to operator. Returns true if the passed in date represents a date this is less than or equal to this date.

Parameters:
inDate The date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date less than or equal to this objects date. Also returns false if the date is not valid.

bool CP_Date::operator<= const CP_String inDateString  ) 
 

Less than or equal to operator. Returns true if the passed in date string represents a date this is less than or equal to this date. The passed in string is first converted to a CP_Date object before comparison. The format of the string must be properly formatted. See operator = for some examples.

Parameters:
inDateString A string representing the date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date less than or equal to this objects date. Also returns false if the date is not valid.

bool CP_Date::operator== const CP_Date inDate  ) 
 

Equality operator. Returns true if the passed in date represents a date this is equal to this date.

Parameters:
inDate The date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date equal to this objects date. Also returns false if the date is not valid.

bool CP_Date::operator== const CP_String inDateString  ) 
 

Equality operator. Returns true if the passed in date string represents a date this is equal to this date. The passed in string is first converted to a CP_Date object before comparison. The format of the string must be properly formatted. See operator = for some examples.

Parameters:
inDateString A string representing the date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date equal to this objects date. Also returns false if the date is not valid.

bool CP_Date::operator!= const CP_Date inDate  ) 
 

Inequality operator. Returns true if the passed in date represents a date this is not equal to this date.

Parameters:
inDate The date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date not equal to this objects date. Also returns false if the date is not valid.

bool CP_Date::operator!= const CP_String inDateString  ) 
 

Inequality operator. Returns true if the passed in date string represents a date this is not equal to this date. The passed in string is first converted to a CP_Date object before comparison. The format of the string must be properly formatted. See operator = for some examples.

Parameters:
inDateString A string representing the date to compare against.
Exceptions:
none 
Returns:
bool Returns true if the passed in date represents a date not equal to this objects date. Also returns false if the date is not valid.

const CP_Date & CP_Date::AddMonths SInt16  inMonths  ) 
 

Adds the passed in number of months to this date, and returns a reference to this date.

Parameters:
inMonths Number of months to add to this date.
Exceptions:
none 
Returns:
CP_Date const Returns a reference to this date.

const CP_Date & CP_Date::SubtractMonths SInt16  inMonths  ) 
 

Subtracts the passed in number of months from this date, and returns a reference to this date.

Parameters:
inMonths Number of months to subtract from this date.
Exceptions:
none 
Returns:
CP_Date const Returns a reference to this date.

const CP_Date & CP_Date::AddYears SInt16  inYears  ) 
 

Adds the passed in number of years to this date, and returns a reference to this date.

Parameters:
inYears Number of years to add to this date.
Exceptions:
none 
Returns:
CP_Date const Returns a reference to this date.

const CP_Date & CP_Date::SubtractYears SInt16  inYears  ) 
 

Subtracts the passed in number of years from this date, and returns a reference to this date.

Parameters:
inMonths Number of years to add to this date.
Exceptions:
none 
Returns:
CP_Date const Returns a reference to this date.

const CP_Date & CP_Date::AddDays SInt16  inDays  ) 
 

Adds the passed in number of days to this date, and returns a reference to this date.

Parameters:
inDays Number of days to add to this date.
Exceptions:
none 
Returns:
CP_Date const Returns a reference to this date.

const CP_Date & CP_Date::SubtractDays SInt16  inDays  ) 
 

Subtracts the passed in number of days to this date, and returns a reference to this date.

Parameters:
inDays Number of days to subtract from this date.
Exceptions:
none 
Returns:
CP_Date const Returns a reference to this date.

SInt16 CP_Date::YearsOld  ) 
 

Returns the age, based on todays date of this date.

Exceptions:
none 
Returns:
SInt16 Number of years old this date is in reference to the current date.

SInt16 CP_Date::ElapsedDays CP_Date inStartDate  ) 
 

Returns the number of elapsed days from the passed in start date to the date stored in this object.

Parameters:
inDate Starting date to compare against.
Exceptions:
none 
Returns:
SInt16 Number of days elapsed between this date, and the passed in starting date.

CP_String CP_Date::Format SInt16  inFormat = CP_DefaultDateFormat  )  const
 

Returns a string containing the formmated output of this date. The passed in format can be one of the following:

  • CP_E_FullDateFormat,
  • CP_E_LongDateFormat,

Parameters:
inFormat The format the output.
Exceptions:
none 
Returns:
CP_String const Returns a formatted string with this date.

void CP_Date::SetToSystemDate  ) 
 

Sets the date represented by this object to that of the platforms.

Exceptions:
none 
Returns:
void

void CP_Date::SetYear SInt16  inYear  ) 
 

Sets the year of this date.

Parameters:
inYear The year of this date.
Exceptions:
none 
Returns:
void

void CP_Date::SetMonth SInt16  inMonth  ) 
 

Sets the month of this date.

Parameters:
inMonth The month of this date.
Exceptions:
none 
Returns:
void

void CP_Date::SetDay SInt16  inDay  ) 
 

Sets the date of this date.

Parameters:
inDay The day of this date.
Exceptions:
none 
Returns:
void

void CP_Date::SetDayOfWeek SInt16  inDayOfWeek  ) 
 

Sets the date of the week of this date.

Parameters:
inDayOfWeek The date of the week of this date.
Exceptions:
none 
Returns:
void

void CP_Date::SetDate LongDateRec  inDateRec  ) 
 

Sets the date from the passed in MacOS LongDateRec.

Parameters:
inDateRec MacOS LongDateRec containing the date.
Exceptions:
none 
Returns:
void

bool CP_Date::IsValid  ) 
 

Tests to see if this date is valid.

Exceptions:
none 
Returns:
void

bool CP_Date::ParseDateString const CP_String inDate,
SInt16 &  inMonth,
SInt16 &  inDay,
SInt16 &  inYear
 

Parses the passed in string into the month, day and year. The results are returned in the passed in data members.

Parameters:
inDate Properly formatted string containing the date to set this object to. See operator = for examples of how to format the date.
inMonth Location to return the month in.
inDay Location to return the day in.
inYear Location to return the year in.
Exceptions:
none 
Returns:
bool Returns true if the date was able to be parsed.

void CP_Date::MDYToJulian  )  [private]
 

Converts the date from MDY format to Julian format. Used internally to convert from the two formats.

Exceptions:
none 
Returns:
none

void CP_Date::JulianToWday  )  [private]
 

Calculats the day of week from the Julian data member.

Exceptions:
none 
Returns:
none

void CP_Date::JulianToMDY  )  [private]
 

Converts Julian data member to the corresponding month, day, year and sets the internal data members to these new values.

Exceptions:
none 
Returns:
none

void CP_Date::AdjustDays  )  [private]
 

Internal routine to adjust the day fields based on the date.

Exceptions:
none 
Returns:
void

bool CP_Date::ParseDateString const CP_String inDate  )  [private]
 

Parses the passed in string into the various fields that this date needs.

Parameters:
inDate Properly formatted string containing the date to set this object to. See operator = for examples of how to format the date.
Exceptions:
none 
Returns:
bool Returns true if the date was able to be parsed.

void CP_Object::SetID FourCharCode  inIdentifier  )  [inherited]
 

Sets the identifier for this object. If a specific identifier is not set with this function, then a default id is used, which is simply a running count of the number of objects created.

Parameters:
inIdentifier The objects identifier.
Returns:
void

FourCharCode CP_Object::GetID  )  [inherited]
 

Returns the objects identifier.

Returns:
FourCharCode The identifier of this object.

void CP_Object::RegisterSignal const CP_SignalHolder inSignal  )  [inherited]
 

Registers the signal / signal name contained in the passed in inSignal object.

Parameters:
inSignal CP_SignalHolder that holds a signal and string identifier.
Returns:
void

CP_DataValueSignal * CP_Object::FindSignal const CP_String inSignalName  )  [inherited]
 

Finds the CP_DataValueSignal object that matches the passed in inSignalName.

Parameters:
inSignalName CP_String containing the identifier of the signal to return.
Returns:
CP_DataValueSignal * Returns a pointer to a CP_DataValueSignal object.

UInt32 CP_Object::GetNumberSignals  )  [inherited]
 

Returns the number of signals for this object.

Returns:
UInt32 The number of signals.

CP_String CP_Object::GetNthSignalName UInt32  inSignalIndex  )  [inherited]
 

Returns the signal name of the passed in signal index.

Parameters:
inSignalIndex Index of the name of the signal to return.
Returns:
CP_String The name of the nth signal being returned.

void CP_Object::RegisterSlot const CP_SlotHolder inSlot  )  [inherited]
 

Registers the slot / slot name contained in the passed in inSlot object.

Parameters:
inSlot CP_SignalHolder that holds a slot and string identifier.
Returns:
void

CP_DataValueSlot CP_Object::FindSlot const CP_String inSlotName  )  [inherited]
 

Finds the CP_Slot1 object that matches the passed in inSlotName.

Parameters:
inSlotName CP_String containing the identifier of the slot to return.
Returns:
CP_DataValueSlot Returns a pointer to a CP_DataValueSlot object.

UInt32 CP_Object::GetNumberSlots  )  [inherited]
 

Returns the number of slots for this object.

Returns:
UInt32 The number of slots.

CP_String CP_Object::GetNthSlotName UInt32  inSlotIndex  )  [inherited]
 

Returns the slot name of the passed in signal index.

Parameters:
inSlotIndex Index of the name of the slot to return.
Returns:
CP_String The name of the nth slot being returned.

template<class R, class P1, class P2>
CP_CommandHandlerSignal* CP_Object::Connect CPLAT::CP_CommandNo  cmd,
void(R::*)(P1, P2)  handler,
SInt32  mode
[inherited]
 

template<class R, class P1, class P2>
void CP_Object::Connect CP_Object control,
const CPLAT::CP_String &  signalName,
void(R::*)(P1, P2)  handler
[inherited]
 

void CP_Object::Connect CP_Object sender,
const CP_String signalName,
CP_Object receiver,
const CP_String slotName,
const bool  reciprocal = false
[static, inherited]
 

void CP_Object::Connect CP_Object sender,
CP_Object receiver,
const bool  reciprocal = false,
const CP_String signalName = kCP_Signal_ValueChanged,
const CP_String slotName = kCP_Slot_SetValue
[static, inherited]
 


Member Data Documentation

SInt16 CP_Date::fYear [protected]
 

SInt16 CP_Date::fMonth [protected]
 

Year of the date.

SInt16 CP_Date::fDay [protected]
 

Month of the date.

SInt16 CP_Date::fDayOfWeek [protected]
 

Day of the date.

UInt32 CP_Date::fJulian [protected]
 

Day of week. 1 = Sunday, 2 = Monday, etc... 7 = Saturday

CP_E_DateFormat CP_Date::fCurrentDateFormat [protected]
 

Julian representation of the date.

CP_E_DateFormatInput CP_Date::fInputDateFormat [protected]
 

Formatting style for output.

CP_Signals_Array* CP_Object::fSignals [protected, inherited]
 

CP_Slots_Array* CP_Object::fSlots [protected, inherited]
 

List of registered signals for this object.

FourCharCode CP_Object::fObjectID [protected, inherited]
 

List of registered slots for this object.

CPLAT_Begin_Namespace_CPLAT FourCharCode CP_Object::fObjectIDCount = 0 [static, protected, inherited]
 

Object identifier.


The documentation for this class was generated from the following files:
Generated on Tue Sep 20 20:21:37 2005 for CPLAT_MacOS by  doxygen 1.4.0