Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class TDateTime

TDateTime

Support

Supported from 5.0

Description

Allows user access to the following components of the time: the year, month, day, hour, minute, second and microsecond, in human-readable form. 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.

Defined in TDateTime:
Day(), Hour(), MicroSecond(), Minute(), Month(), Second(), Set(), SetDay(), SetHour(), SetMicroSecond(), SetMinute(), SetMonth(), SetSecond(), SetYear(), SetYearLeapCheck(), TDateTime(), Year()

See also:


Construction and destruction


TDateTime()

TDateTime();

Description

Constructs an uninitialised TDateTime object. It is necessary because there is also a non-default constructor in this class.


TDateTime()

TDateTime(TInt aYear,TMonth aMonth,TInt aDay,TInt aHour,TInt aMinute, TInt aSecond,TInt aMicroSecond);

Description

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

Note:

Parameters

TInt aYear

The year. No check is made for validity.

TMonth aMonth

The month. Range is EJanuary to EDecember.

TInt aDay

The day. Range is zero to number of days in month minus one.

TInt aHour

The hour. Range is 0 to 23.

TInt aMinute

The minute. Range is 0 to 59.

TInt aSecond

The second. Range is 0 to 59

TInt aMicroSecond

The microsecond. Range is 0 to 999999

See also:

[Top]


Setting date and time


Set()

TInt Set(TInt aYear,TMonth aMonth,TInt aDay,TInt aHour,TInt aMinute, TInt aSecond,TInt aMicroSecond);

Description

Sets all date and time components.

Notes:

Parameters

TInt aYear

Year. 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 aMonth

Month. 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 aDay

The 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 aHour

Hour. Range is 0 to 23.

TInt aMinute

Minute. Range is 0 to 59.

TInt aSecond

Second. Range is 0 to 59.

TInt aMicroSecond

Microsecond. Range is 0 to 999999.

Return value

TInt

KErrNone if successful, KErrGeneral if not.

See also:


SetYear()

TInt SetYear(TInt aYear);

Description

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 aYear

The year.

Return value

TInt

KErrNone if successful, KErrGeneral if not.


SetYearLeapCheck()

TInt SetYearLeapCheck(TInt aYear);

Description

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.

Parameters

TInt aYear

The year.

Return value

TInt

KErrNone if successful, KErrGeneral if not.


SetMonth()

TInt SetMonth(TMonth aMonth);

Description

Sets the month component of the date/time.

Parameters

TMonth aMonth

The month. 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.

Return value

TInt

KErrNone if the successful, KErrGeneral if not.


SetDay()

TInt SetDay(TInt aDay);

Description

Sets the day component of the date/time.

Parameters

TInt aDay

The 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.

Return value

TInt

KErrNone if successful, KErrGeneral if not.


SetHour()

TInt SetHour(TInt aHour);

Description

Sets the hour component of the date/time.

Parameters

TInt aHour

The hour. Range is 0 to 23.

Return value

TInt

KErrNone if successful, KErrGeneral if not.


SetMinute()

TInt SetMinute(TInt aMinute);

Description

Sets the minute component of the date/time.

Parameters

TInt aMinute

The minute. Range is 0 to 59.

Return value

TInt

KErrNone if successful, KErrGeneral if not.


SetSecond()

TInt SetSecond(TInt aSecond);

Description

Sets the second component of the date/time.

Parameters

TInt aSecond

The second. Range is 0 to 59.

Return value

TInt

KErrNone if successful, KErrGeneral if not.


SetMicroSecond()

TInt SetMicroSecond(TInt aMicroSecond);

Description

Sets the microsecond component of the date/time.

Parameters

TInt aMicroSecond

The microsecond. Range is 0 to 999999.

Return value

TInt

KErrNone if successful, KErrGeneral if not.

[Top]


Get date and time components


Year()

TInt Year() const;

Description

Gets the year component of the date/time. A negative value indicates a BC date.

Return value

TInt

The year


Month()

TMonth Month() const;

Description

Gets the month component of the date/time.

Return value

TMonth

The month. EJanuary to EDecember. Offset from zero, so add one before displaying the month number.


Day()

TInt Day() const;

Description

Gets the day component of the date/time.

Return value

TInt

The day. Offset from zero, so add one before displaying the day number.


Hour()

TInt Hour() const;

Description

Gets the hour component of the date/time.

Return value

TInt

The hour.


Minute()

TInt Minute() const;

Description

Gets the minute component of the date/time.

Return value

TInt

The minute.


Second()

TInt Second() const;

Description

Gets the second component of the date/time.

Return value

TInt

The second.


MicroSecond()

TInt MicroSecond() const;

Description

Gets the microsecond component of the date/time.

Return value

TInt

The microsecond.