TDateTime Class Reference

class TDateTime

A date and time object in which the individual components are accessible in human-readable form.

The individual components are: year, month, day, hour, minute, second and microsecond.

These components are stored as integers and all except the year are checked for validity when a TDateTime is constructed or assigned new values.

This class only supports getting and setting the entire date/time or any component of it. It does not support adding or subtracting intervals to or from a time. For functions which manipulate times, use class TTime.

TTime

Constructor & Destructor Documentation

TDateTime()

TDateTime()[inline]

Constructs an uninitialised TDateTime object.

TDateTime(TInt, TMonth, TInt, TInt, TInt, TInt, TInt)

IMPORT_CTDateTime(TIntaYear,
TMonthaMonth,
TIntaDay,
TIntaHour,
TIntaMinute,
TIntaSecond,
TIntaMicroSecond
)

Constructs the TDateTime object with the seven fields which comprise a date and time.

panic
USER 3, if an attempt is made to set an invalid value for any of the fields, except for the year. No check is made upon the validity of the year.

Parameters

TInt aYearThe year. No check is made for validity.
TMonth aMonthThe month. Range is EJanuary to EDecember.
TInt aDayThe day. Range is zero to number of days in month minus one.
TInt aHourThe hour. Range is 0 to 23.
TInt aMinuteThe minute. Range is 0 to 59.
TInt aSecondThe second. Range is 0 to 59
TInt aMicroSecondThe microsecond. Range is 0 to 999999

Member Functions Documentation

Day()

TInt Day()const [inline]

Gets the day component of the date/time.

Hour()

TInt Hour()const [inline]

Gets the hour component of the date/time.

MicroSecond()

TInt MicroSecond()const [inline]

Gets the microsecond component of the date/time.

Minute()

TInt Minute()const [inline]

Gets the minute component of the date/time.

Month()

TMonth Month()const [inline]

Gets the month component of the date/time.

Second()

TInt Second()const [inline]

Gets the second component of the date/time.

Set(TInt, TMonth, TInt, TInt, TInt, TInt, TInt)

IMPORT_C TIntSet(TIntaYear,
TMonthaMonth,
TIntaDay,
TIntaHour,
TIntaMinute,
TIntaSecond,
TIntaMicroSecond
)

Sets all date and time components.

Note:

1. When setting the day and month, subtract one because the ranges are offset from zero.

2. If the function returns an error, only those fields preceding the field which caused the error will be changed. For example, if the hour is out of range, the year, month and day will be set, all other components will remain unchanged.

Parameters

TInt aYearYear. No check is made on its validity, except that if the date is set to February 29th, the year can only be set to a leap year, otherwise an error is returned.
TMonth aMonthMonth. The valid range is EJanuary to EDecember. If an attempt is made to set an invalid month, or if the current day number in the month is greater than or equal to the number of days in the new month, an error is returned.
TInt aDayThe number of the day within the month, offset from zero. If greater than or equal to the total number of days in the month,an error is returned.
TInt aHourHour. Range is 0 to 23.
TInt aMinuteMinute. Range is 0 to 59.
TInt aSecondSecond. Range is 0 to 59.
TInt aMicroSecondMicrosecond. Range is 0 to 999999.

SetDay(TInt)

IMPORT_C TIntSetDay(TIntaDay)

Sets the day component of the date/time.

Parameters

TInt aDayThe number of the day within the month, offset from zero. If equal to or greater than the total number of days in the month, an error is returned.

SetHour(TInt)

IMPORT_C TIntSetHour(TIntaHour)

Sets the hour component of the date/time.

Parameters

TInt aHourThe hour. Range is 0 to 23.

SetMicroSecond(TInt)

IMPORT_C TIntSetMicroSecond(TIntaMicroSecond)

Sets the microsecond component of the date/time.

Parameters

TInt aMicroSecondThe microsecond. Range is 0 to 999999.

SetMinute(TInt)

IMPORT_C TIntSetMinute(TIntaMinute)

Sets the minute component of the date/time.

Parameters

TInt aMinuteThe minute. Range is 0 to 59.

SetMonth(TMonth)

IMPORT_C TIntSetMonth(TMonthaMonth)

Sets the month component of the date/time.

Parameters

TMonth aMonthThe month to be set. The range is from EJanuary to EDecember. If an attempt is made to set an invalid month, or if the current day number in the month is greater than or equal to the number of days in the new month, an error is returned.

SetSecond(TInt)

IMPORT_C TIntSetSecond(TIntaSecond)

Sets the second component of the date/time.

Parameters

TInt aSecondThe second. Range is 0 to 59.

SetYear(TInt)

IMPORT_C TIntSetYear(TIntaYear)

Sets the year without a leap year check.

No check is made on the validity of the year except that if the current date is February 29th, the year can only be changed to another leap year, otherwise an error is returned.

Parameters

TInt aYearThe year.

SetYearLeapCheck(TInt)

IMPORT_C TIntSetYearLeapCheck(TIntaYear)

Sets the year with a leap year check.

Unlike SetYear(), if the date is the 29th February, this function allows the year to be set to a non-leap year. In this case, the date is reset to the 28th February.

TDateTime::SetYear

Parameters

TInt aYearThe year.

Year()

TInt Year()const [inline]

Gets the year component of the date/time.

A negative value indicates a BC date.

Member Data Documentation

TInt iDay

TInt iDay[private]

TInt iHour

TInt iHour[private]

TInt iMicroSecond

TInt iMicroSecond[private]

TInt iMinute

TInt iMinute[private]

TMonth iMonth

TMonth iMonth[private]

TInt iSecond

TInt iSecond[private]

TInt iYear

TInt iYear[private]