Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class TTime

class TTime;

Description

Stores and manipulates the date and time.

It represents a date and time as a number of microseconds since midnight, January 1st, 0 AD nominal Gregorian. BC dates are represented by negative TTime values. A TTime object may be constructed from a TInt64, a TDateTime a string literal, or by default, which initialises the time to an arbitrary value. To access human-readable time information, the TTime may be converted from a TInt64 into a TDateTime, which represents the date and time as seven numeric fields and provides functions to extract these fields. Alternatively, to display the time as text, the time may be formatted and placed into a descriptor using a variety of formatting commands and which may or may not honour the system's locale settings. The conversion between time and text may be performed the other way around, so that a descriptor can be parsed and converted into a TTime value.

In addition to setting and getting the date and time and converting between text and time, TTime provides functions to get intervals between times and standard comparison and arithmetic operators which enable time intervals to be added or subtracted to or from the time.

Members

Defined in TTime:
DateTime(), DayNoInMonth(), DayNoInWeek(), DayNoInYear(), DayNoInYear(), DaysFrom(), DaysInMonth(), FormatL(), FormatL(), HomeTime(), HoursFrom(), Int64(), MicroSecondsFrom(), MinutesFrom(), MonthsFrom(), Parse(), RoundUpToNextMinute(), SecondsFrom(), Set(), TTime(), TTime(), TTime(), TTime(), UniversalTime(), WeekNoInYear(), WeekNoInYear(), WeekNoInYear(), WeekNoInYear(), YearsFrom(), operator!=(), operator>(), operator>=(), operator<(), operator<=(), operator+(), operator+(), operator+(), operator+(), operator+(), operator+(), operator+(), operator+(), operator+=(), operator+=(), operator+=(), operator+=(), operator+=(), operator+=(), operator+=(), operator+=(), operator-(), operator-(), operator-(), operator-(), operator-(), operator-(), operator-(), operator-(), operator-=(), operator-=(), operator-=(), operator-=(), operator-=(), operator-=(), operator-=(), operator-=(), operator=(), operator=(), operator==()

See also

See also:


Construction and destruction


TTime()

inline TTime();

Description

Default constructor.

The object is initialised to an arbitrary value.


TTime()

inline TTime(const TInt64 &aTime);

Description

Constructs the object from a 64-bit microsecond value.

Parameters

const TInt64 &aTime

Microsecond value to which to initialise the TTime object.


TTime()

IMPORT_C TTime(const TDesC &aString);

Description

Constructs a TTime object with a text string.

The string consists of up to three components, any or all of which may be omitted:

1. year, month and day, followed by a colon

2. hour, minute and second, followed by a dot

3. microsecond

When all three components are present, the string should take the form:

YYYYMMDD:HHMMSS.MMMMMM

The conversion from text to time is carried out in the same manner as that used in TTime::Set().

For a list of the range of valid values for date and time components, see TDateTime::Set().

Parameters

const TDesC &aString

Date and time string for initializing the TTime object.

Panic codes

USER

113, if the string is syntactically incorrect, for example, if neither a colon nor a dot is present, or if any component of the date or time is assigned an invalid value, or the year is negative.


TTime()

IMPORT_C TTime(const TDateTime &aDateTime);

Description

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

Parameters

const TDateTime &aDateTime

Date and time to which to initialise the TTime object.

[Top]


Member functions


operator=()

inline TTime &operator=(const TInt64 &aTime);

Description

Assigns a value contained in a 64-bit integer to this TTime object.

Parameters

const TInt64 &aTime

Microsecond value which to assign to the TTime object.

Return value

TTime &

This TTime object.


operator=()

IMPORT_C TTime &operator=(const TDateTime &aDateTime);

Description

Assigns a TDateTime object to this TTime object.

Parameters

const TDateTime &aDateTime

The date and time to assign to this TTime object.

Return value

TTime &

This TTime object.


HomeTime()

IMPORT_C void HomeTime();

Description

Sets the date and time of this TTime to the home time.


UniversalTime()

IMPORT_C void UniversalTime();

Description

Sets the date and time of this TTime to the universal time.


Set()

IMPORT_C TInt Set(const TDesC &aString);

Description

Assigns a date and time contained in a descriptor to this TTime object.

The string consists of up to three components, any or all of which may be omitted:

1. year, month and day, followed by a colon

2. hour, minute and second, followed by a dot

3. microsecond

When all three components are present, the string should take the form:

YYYYMMDD:HHMMSS.MMMMMM

If omitted, the first component is set to January 1st 0 AD nominal Gregorian. If either the second or third components are omitted, they are set to zero.

Notes:

1. The month and day values are offset from zero.

2. The only situations in which either the colon or dot may be omitted are as follows:

2.1 If the microsecond component is omitted, the preceding dot may also be omitted.

2.2 The colon can be omitted only if a dot is located at string position zero (indicating that the first two components are missing), or at string position six (indicating that the first component only is missing).

Parameters

const TDesC &aString

The date and time to be assigned to this TTime object.

Return value

TInt

KErrNone if successful, KErrGeneral if the string is syntactically incorrect, for example, if neither a colon nor a dot is present, or if any component of the date or time is given an invalid value, or the year is negative. For a list of valid values for date and time components, see TDateTime::Set(). If an error occurs, the date and time will remain unchanged.


DateTime()

IMPORT_C TDateTime DateTime() const;

Description

Converts the TTime object into a TDateTime object.

This conversion must be done before the seven fields which comprise a date and time can be accessed.

Return value

TDateTime

The components of the time, indicating year, month, day, hour, minute, second, microsecond.


MicroSecondsFrom()

IMPORT_C TTimeIntervalMicroSeconds MicroSecondsFrom(TTime aTime) const;

Description

Calculates the number of microseconds difference between the specified TTime and this TTime.

Parameters

TTime aTime

The time to be compared with this TTime.

Return value

TTimeIntervalMicroSeconds

Difference in microseconds between the two times. If the time specified in the argument is later than this TTime, this value is negative.


SecondsFrom()

IMPORT_C TInt SecondsFrom(TTime aTime, TTimeIntervalSeconds &aInterval) const;

Description

Calculates the number of seconds difference between the specified TTime and this TTime.

The difference may be positive or negative.

Parameters

TTime aTime

The time to be compared with this TTime.

TTimeIntervalSeconds &aInterval

On return contains the difference in seconds between the two times. If the time specified in the first argument is later than this TTime, then this returned value is negative.

Return value

TInt

Error code. KErrNone if successful. KErrOverflow, if the calculated interval is too large for a 32-bit integer.


MinutesFrom()

IMPORT_C TInt MinutesFrom(TTime aTime, TTimeIntervalMinutes &aInterval) const;

Description

Calculates the number of minutes difference between the specified TTime and this TTime.

The difference may be positive or negative.

Parameters

TTime aTime

The time to be compared with this TTime.

TTimeIntervalMinutes &aInterval

On return contains the difference in minutes between the two times. If the time specified in the first argument is later than this TTime, then this returned value is negative.

Return value

TInt

Error code. KErrNone if successful. KErrOverflow, if the calculated interval is too large for a 32-bit integer.


HoursFrom()

IMPORT_C TInt HoursFrom(TTime aTime, TTimeIntervalHours &aInterval) const;

Description

Calculates the number of hours difference between the specified TTime and this TTime.

The difference may be positive or negative.

Parameters

TTime aTime

The time to be compared with this TTime.

TTimeIntervalHours &aInterval

On return contains the difference in hours between the two times. If the time specified in the first argument is later than this TTime, then this returned value is negative.

Return value

TInt

Error code. KErrNone if successful. KErrOverflow, if the calculated interval is too large for a 32-bit integer.


DaysFrom()

IMPORT_C TTimeIntervalDays DaysFrom(TTime aTime) const;

Description

Calculates the number of days difference between the specified TTime and this TTime.

The difference may be positive or negative.

Parameters

TTime aTime

The time to be compared with this TTime.

Return value

TTimeIntervalDays

Difference in days between the two times. If the time specified in aTime is later than this TTime, the returned value will be negative.


MonthsFrom()

IMPORT_C TTimeIntervalMonths MonthsFrom(TTime aTime) const;

Description

Calculates the number of months between the specified TTime and this TTime.

The result may be positive or negative.

The interval in months between two TTimes is calculated by incrementing it by one each time the same day number and time in the previous or following month has been reached. Exceptions to this rule occur when this TTime is on the last day of the month. In this case, the following rules apply:

When comparing this TTime with a later time:

1. if the following month is shorter, one month is deemed to separate the times when the same time on the last day of the following month is reached. In this case, the two day numbers are not the same.

When comparing this TTime with an earlier time:

1. if the previous month is shorter, one month is deemed to separate the times when the last microsecond of the previous month is reached (23:59:59.999999 on the last day of the month).

2. if the previous month is longer, one month is deemed to separate the times when the same time on the last day of previous month is reached. In this case, the two day numbers are not the same.

Parameters

TTime aTime

The time to be compared with this TTime.

Return value

TTimeIntervalMonths

Difference in months between the two times. If the time specified in the argument is later than this TTime, the interval is negative.


YearsFrom()

IMPORT_C TTimeIntervalYears YearsFrom(TTime aTime) const;

Description

Calculates the number of years between the specified TTime and this TTime.

The result may be positive or negative.

Note that the interval in years between two TTimes is calculated by incrementing it by one each time the same day number and time in the previous or following year has been reached. The exception to this rule occurs when this TTime is the last day in February in a leap year. In this case, one year is deemed to have passed when the same time of day on the last day in the preceding or following February has been reached.

Parameters

TTime aTime

The time to be compared with this TTime.

Return value

TTimeIntervalYears

Difference in years between the two times. If the time specified in the argument is later than this TTime, the interval is negative.


DaysInMonth()

IMPORT_C TInt DaysInMonth() const;

Description

Gets the number of days in the current month.

Return value

TInt

The number of days in the month.


DayNoInWeek()

IMPORT_C TDay DayNoInWeek() const;

Description

Gets the day number within the current week.

This is a value in the range zero to six inclusive, and honours the setting specified in TLocale::SetStartOfWeek().

By default the first day in the week is Monday.

Return value

TDay

The number of the day within the week. The range is EMonday to ESunday.


DayNoInMonth()

IMPORT_C TInt DayNoInMonth() const;

Description

Gets the day number in the month.

Return value

TInt

The day number in the month. The first day in the month is numbered zero.


DayNoInYear()

IMPORT_C TInt DayNoInYear() const;

Description

Gets the day number in the year.

Return value

TInt

The day number in the year. The first day in the year is day one.


DayNoInYear()

IMPORT_C TInt DayNoInYear(TTime aStartDate) const;

Description

Gets the day number in the year when the start of the year is aStartDate.

If no start date is specified, the default is January 1st.

Parameters

TTime aStartDate

Indicates the date which is to be considered the start of the year. Default is 1st January.

Return value

TInt

The day number in the year. The first day in the year is day one.


WeekNoInYear()

IMPORT_C TInt WeekNoInYear() const;

Description

Gets the number of the current week in the year.

Return value

TInt

Week number in the year.


WeekNoInYear()

IMPORT_C TInt WeekNoInYear(TTime aStartDate) const;

Description

Gets the number of the current week in the year when the year starts on aStartDate.

Parameters

TTime aStartDate

If specified, indicates the date which is to be considered the start of the year. Default is 1st January.

Return value

TInt

Week number in the year.


WeekNoInYear()

IMPORT_C TInt WeekNoInYear(TFirstWeekRule aRule) const;

Description

Finds the number of the current week in the year using the first week rule specified in aRule.

Parameters

TFirstWeekRule aRule

Determines how the first week in the year is to be calculated. By default EFirstFourDayWeek.

Return value

TInt

Week number in the year.


WeekNoInYear()

IMPORT_C TInt WeekNoInYear(TTime aStartDate, TFirstWeekRule aRule) const;

Description

Finds the number of the current week in the year when the year starts from aStartDate and when using the start week rule aRule.

Parameters

TTime aStartDate

If specified, indicates the date which is to be considered the start of the year. Default is 1st January.

TFirstWeekRule aRule

Determines how the first week in the year is to be calculated. By default EFirstFourDayWeek.

Return value

TInt

Week number in the year.


FormatL()

IMPORT_C void FormatL(TDes &aDes, const TDesC &aFormat) const;

Description

Puts this TTime into a descriptor and formats it according to the format string specified in the second argument.

Many of the formatting commands use the system's locale settings for the date and time, for example the characters used to separate components of the date and time and the ordering of day, month and year. The list of formatting commands below is divided into two sections, the first of which lists the commands which operate without reference to the locale's date and time settings (see class TLocale) and the second table lists the commands which do use these settings.

The following formatting commands do not honour the locale-specific system settings:

%% : Include a single '%' character in the string

%* : Abbreviate following item (the following item should not be preceded by a '%' character).

%C : Interpret the argument as the six digit microsecond component of the time. In its abbreviated form, ('%*C') this should be followed by an integer between zero and six, where the integer indicates the number of digits to display.

%D : Interpret the argument as the two digit day number in the month. Abbreviation suppresses leading zero.

%E : Interpret the argument as the day name. Abbreviation is language-specific (e.g. English uses the first three letters).

%F : Use this command for locale-independent ordering of date components. This orders the following day/month/year component(s) (%D, %M, %Y for example) according to the order in which they are specified in the string. This removes the need to use %1 to %5 (described below).

%H : Interpret the argument as the one or two digit hour component of the time in 24 hour time format. Abbreviation suppresses leading zero. For locale-dependent hour formatting, use %J.

%I : Interpret the argument as the one or two digit hour component of the time in 12 hour time format. The leading zero is automatically suppressed so that abbreviation has no effect. For locale-dependent hour formatting, use %J.

%M : Interpret the argument as the one or two digit month number. Abbreviation suppresses leading zero.

%N : Interpret the argument as the month name. Abbreviation is language specific, e.g. English uses the first three letters only. When using locale-dependent formatting, (that is, %F has not previously been specified), specifying %N causes any subsequent occurrence of a month specifier in the string to insert the month as text rather than in numeric form. When using locale-independent formatting, specifying %N causes the month to be inserted as text at that position, but any subsequent occurrence of %M will cause the month to be inserted in numeric form.

%S : Interpret the argument as the one or two digit seconds component of the time. Abbreviation suppresses leading zero.

%T : Interpret the argument as the one or two digit minutes component of the time. Abbreviation suppresses leading zero.

%W : Interpret the argument as the one or two digit week number in year. Abbreviation suppresses leading zero.

%X : Interpret the argument as the date suffix. Cannot be abbreviated. When using locale-dependent formatting (that is, %F has not previously been specified), %X causes all further occurrences of the day number to be displayed with the date suffix. When using locale-independent formatting, a date suffix will be inserted only after the occurrence of the day number which %X follows in the format string. Any further occurrence of %D without a following %X will insert the day number without a suffix.

%Y : Interpret the argument as the four digit year number. Abbreviation suppresses the first two digits.

%Z : Interpret the argument as the one, two or three digit day number in the year. Abbreviation suppresses leading zeros.

The following formatting commands do honour the locale-specific system settings:

%. : Interpret the argument as the decimal separator character (as set by TLocale::SetDecimalSeparator()). The decimal separator is used to separate seconds and microseconds, if present.

%: : Interpret the argument as one of the four time separator characters (as set by TLocale::SetTimeSeparator()). Must be followed by an integer between zero and three inclusive to indicate which time separator character is being referred to.

%/ : Interpret the argument as one of the four date separator characters (as set by TLocale::SetDateSeparator()). Must be followed by an integer between zero and three inclusive to indicate which date separator character is being referred to.

%1 : Interpret the argument as the first component of a three component date (i.e. day, month or year) where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean, this is the day, when EDateAmerican, the month, and when EDateJapanese, the year. For more information on this and the following four formatting commands, see the Notes section immediately below.

%2 : Interpret the argument as the second component of a three component date where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean, this is the month, when EDateAmerican, the day and when EDateJapanese, the month.

%3 : Interpret the argument as the third component of a three component date where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean, or EDateAmerican this is the year and when EDateJapanese, the day.

%4 : Interpret the argument as the first component of a two component date (day and month) where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean this is the day, and when EDateAmerican or EDateJapanese, the month.

%5 : Interpret the argument as the second component of a two component date (day and month) where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean this is the month, and when EDateAmerican or EDateJapanese, the day.

%A : Interpret the argument as "am" or "pm" text according to the current language and time of day. Unlike the %B formatting command (described below), %A disregards the locale's 12 or 24 hour clock setting, so that when used without an inserted + or - sign, am/pm text will always be displayed. Whether a space is inserted between the am/pm text and the time depends on the locale-specific settings. However, if abbreviated (%*A), no space is inserted, regardless of the locale's settings. The am/pm text appears before or after the time, according to the position of the %A, regardless of the locale-specific settings. For example, the following ordering of formatting commands causes am/pm text to be printed after the time: %H %T %S %A. Optionally, a minus or plus sign may be inserted between the "%" and the "A". This operates as follows:

%-A causes am/pm text to be inserted into the descriptor only if the am/pm symbol position has been set in the locale to ELocaleBefore. Cannot be abbreviated using asterisk.

%+A causes am/pm text to be inserted into the descriptor only if the am/pm symbol position has been set in the locale to ELocaleAfter. Cannot be abbreviated using asterisk. For example, the following formatting commands will cause am/pm text to be displayed after the time if the am/pm position has been set in the locale to ELocaleAfter or before the time if ELocaleBefore: %-A %H %T %S %+A.

%B Interpret the argument as am or pm text according to the current language and time of day. Unlike the %A command, when using %B, am/pm text is displayed only if the clock setting in the locale is 12-hour. Whether a space is inserted between the am/pm text and the time depends on the locale-specific settings. However, if abbreviated (%*B), no space is inserted, regardless of the locale's settings. The am/pm text appears before or after the time, according to the location of the "%B", regardless of the locale-specific settings. For example, the following formatting commands cause am/pm text to be printed after the time: %H %T %S %B. Optionally, a minus or plus sign may be inserted between the "%" and the "B". This operates as follows:

%-B causes am/pm text to be inserted into the descriptor only if using a 12 hour clock and the am/pm symbol position has been set in the locale to ELocaleBefore. Cannot be abbreviated using asterisk.

%+B causes am/pm text to be inserted into the descriptor only if using a 12 hour clock and the am/pm symbol position has been set in the locale to ELocaleAfter. Cannot be abbreviated using asterisk. For example, the following formatting commands cause am/pm text to be printed after the time if the am/pm position has been set in the locale to ELocaleAfter or before the time if ELocaleBefore: %-B %H %T %S %+B.

%J Interpret the argument as the hour component of the time in either 12 or 24 hour clock format depending on the locale's clock format setting. When the clock format has been set to 12 hour, leading zeros are automatically suppressed so that abbreviation has no effect. Abbreviation suppresses leading zero only when using a 24 hour clock.

Notes:

The %1, %2, %3, %4 and %5 formatting commands are used in conjunction with %D, %M and %Y to format the date locale-dependently. When formatting the date locale-dependently, the order of the day, month and year components within the string is determined by the order of the %1 to %5 formatting commands, not that of %D, %M, %Y.

When formatting the date locale-independently (that is, %F has been specified in the format string), the %1 to %5 formatting commands are not required, and should be omitted. In this case, the order of the date components is determined by the order of the %D, %M, %Y format commands within aFormat.

Up to four date separators and up to four time separators can be used to separate the components of a date or time. When formatting a numerical date consisting of the day, month and year or a time containing hours, minutes and seconds, all four separators should always be specified in the format command string. Usually, the leading and trailing separators should not be displayed. In this case, the first and fourth separators should still be specified, but should be represented by a null character.

The date format follows the pattern:

DateSeparator[0] DateComponent1 DateSeparator[1] DateComponent2 DateSeparator[2] DateComponent3 DateSeparator[3]

where the ordering of date components is determined by the locale's date format setting.

The time format follows the pattern:

TimeSeparator[0] Hours TimeSeparator[1] Minutes TimeSeparator[2] Seconds TimeSeparator[3]

If the time includes a microseconds component, the third separator should occur after the microseconds, and the seconds and microseconds should be separated by the decimal separator. When formatting a two component time, the following rules apply:

if the time consists of hours and minutes, the third time delimiter should be omitted

if the time consists of minutes and seconds, the second time delimiter should be omitted

Parameters

TDes &aDes

Descriptor, which, on return contains the formatted date/time string.

const TDesC &aFormat

Format string which determines the format of the date and time.

Leave codes

KErrOverflow

The date/time string is too long for the descriptor aDes.

KErrGeneral

A formatting error has occurred.


FormatL()

IMPORT_C void FormatL(TDes &aDes, const TDesC &aFormat, const TLocale &aLocale) const;

Description

Puts this TTime into a descriptor and formats it according to the format string specified in the second argument.

Many of the formatting commands use the system's locale settings for the date and time, for example the characters used to separate components of the date and time and the ordering of day, month and year. The list of formatting commands below is divided into two sections, the first of which lists the commands which operate without reference to the locale's date and time settings (see class TLocale) and the second table lists the commands which do use these settings.

The following formatting commands do not honour the locale-specific system settings:

%% : Include a single '%' character in the string

%* : Abbreviate following item (the following item should not be preceded by a '%' character).

%C : Interpret the argument as the six digit microsecond component of the time. In its abbreviated form, ('%*C') this should be followed by an integer between zero and six, where the integer indicates the number of digits to display.

%D : Interpret the argument as the two digit day number in the month. Abbreviation suppresses leading zero.

%E : Interpret the argument as the day name. Abbreviation is language-specific (e.g. English uses the first three letters).

%F : Use this command for locale-independent ordering of date components. This orders the following day/month/year component(s) (%D, %M, %Y for example) according to the order in which they are specified in the string. This removes the need to use %1 to %5 (described below).

%H : Interpret the argument as the one or two digit hour component of the time in 24 hour time format. Abbreviation suppresses leading zero. For locale-dependent hour formatting, use %J.

%I : Interpret the argument as the one or two digit hour component of the time in 12 hour time format. The leading zero is automatically suppressed so that abbreviation has no effect. For locale-dependent hour formatting, use %J.

%M : Interpret the argument as the one or two digit month number. Abbreviation suppresses leading zero.

%N : Interpret the argument as the month name. Abbreviation is language specific, e.g. English uses the first three letters only. When using locale-dependent formatting, (that is, %F has not previously been specified), specifying %N causes any subsequent occurrence of a month specifier in the string to insert the month as text rather than in numeric form. When using locale-independent formatting, specifying %N causes the month to be inserted as text at that position, but any subsequent occurrence of %M will cause the month to be inserted in numeric form.

%S : Interpret the argument as the one or two digit seconds component of the time. Abbreviation suppresses leading zero.

%T : Interpret the argument as the one or two digit minutes component of the time. Abbreviation suppresses leading zero.

%W : Interpret the argument as the one or two digit week number in year. Abbreviation suppresses leading zero.

%X : Interpret the argument as the date suffix. Cannot be abbreviated. When using locale-dependent formatting (that is, %F has not previously been specified), %X causes all further occurrences of the day number to be displayed with the date suffix. When using locale-independent formatting, a date suffix will be inserted only after the occurrence of the day number which %X follows in the format string. Any further occurrence of %D without a following %X will insert the day number without a suffix.

%Y : Interpret the argument as the four digit year number. Abbreviation suppresses the first two digits.

%Z : Interpret the argument as the one, two or three digit day number in the year. Abbreviation suppresses leading zeros.

The following formatting commands do honour the locale-specific system settings:

%. : Interpret the argument as the decimal separator character (as set by TLocale::SetDecimalSeparator()). The decimal separator is used to separate seconds and microseconds, if present.

%: : Interpret the argument as one of the four time separator characters (as set by TLocale::SetTimeSeparator()). Must be followed by an integer between zero and three inclusive to indicate which time separator character is being referred to.

%/ : Interpret the argument as one of the four date separator characters (as set by TLocale::SetDateSeparator()). Must be followed by an integer between zero and three inclusive to indicate which date separator character is being referred to.

%1 : Interpret the argument as the first component of a three component date (i.e. day, month or year) where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean, this is the day, when EDateAmerican, the month, and when EDateJapanese, the year. For more information on this and the following four formatting commands, see the Notes section immediately below.

%2 : Interpret the argument as the second component of a three component date where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean, this is the month, when EDateAmerican, the day and when EDateJapanese, the month.

%3 : Interpret the argument as the third component of a three component date where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean, or EDateAmerican this is the year and when EDateJapanese, the day.

%4 : Interpret the argument as the first component of a two component date (day and month) where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean this is the day, and when EDateAmerican or EDateJapanese, the month.

%5 : Interpret the argument as the second component of a two component date (day and month) where the order has been set by TLocale::SetDateFormat(). When the date format is EDateEuropean this is the month, and when EDateAmerican or EDateJapanese, the day.

%A : Interpret the argument as "am" or "pm" text according to the current language and time of day. Unlike the %B formatting command (described below), %A disregards the locale's 12 or 24 hour clock setting, so that when used without an inserted + or - sign, am/pm text will always be displayed. Whether a space is inserted between the am/pm text and the time depends on the locale-specific settings. However, if abbreviated (%*A), no space is inserted, regardless of the locale's settings. The am/pm text appears before or after the time, according to the position of the %A, regardless of the locale-specific settings. For example, the following ordering of formatting commands causes am/pm text to be printed after the time: %H %T %S %A. Optionally, a minus or plus sign may be inserted between the "%" and the "A". This operates as follows:

%-A causes am/pm text to be inserted into the descriptor only if the am/pm symbol position has been set in the locale to ELocaleBefore. Cannot be abbreviated using asterisk.

%+A causes am/pm text to be inserted into the descriptor only if the am/pm symbol position has been set in the locale to ELocaleAfter. Cannot be abbreviated using asterisk. For example, the following formatting commands will cause am/pm text to be displayed after the time if the am/pm position has been set in the locale to ELocaleAfter or before the time if ELocaleBefore: %-A %H %T %S %+A.

%B Interpret the argument as am or pm text according to the current language and time of day. Unlike the %A command, when using %B, am/pm text is displayed only if the clock setting in the locale is 12-hour. Whether a space is inserted between the am/pm text and the time depends on the locale-specific settings. However, if abbreviated (%*B), no space is inserted, regardless of the locale's settings. The am/pm text appears before or after the time, according to the location of the "%B", regardless of the locale-specific settings. For example, the following formatting commands cause am/pm text to be printed after the time: %H %T %S %B. Optionally, a minus or plus sign may be inserted between the "%" and the "B". This operates as follows:

%-B causes am/pm text to be inserted into the descriptor only if using a 12 hour clock and the am/pm symbol position has been set in the locale to ELocaleBefore. Cannot be abbreviated using asterisk.

%+B causes am/pm text to be inserted into the descriptor only if using a 12 hour clock and the am/pm symbol position has been set in the locale to ELocaleAfter. Cannot be abbreviated using asterisk. For example, the following formatting commands cause am/pm text to be printed after the time if the am/pm position has been set in the locale to ELocaleAfter or before the time if ELocaleBefore: %-B %H %T %S %+B.

%J Interpret the argument as the hour component of the time in either 12 or 24 hour clock format depending on the locale's clock format setting. When the clock format has been set to 12 hour, leading zeros are automatically suppressed so that abbreviation has no effect. Abbreviation suppresses leading zero only when using a 24 hour clock.

Notes:

The %1, %2, %3, %4 and %5 formatting commands are used in conjunction with %D, %M and %Y to format the date locale-dependently. When formatting the date locale-dependently, the order of the day, month and year components within the string is determined by the order of the %1 to %5 formatting commands, not that of %D, %M, %Y.

When formatting the date locale-independently (that is, %F has been specified in the format string), the %1 to %5 formatting commands are not required, and should be omitted. In this case, the order of the date components is determined by the order of the %D, %M, %Y format commands within aFormat.

Up to four date separators and up to four time separators can be used to separate the components of a date or time. When formatting a numerical date consisting of the day, month and year or a time containing hours, minutes and seconds, all four separators should always be specified in the format command string. Usually, the leading and trailing separators should not be displayed. In this case, the first and fourth separators should still be specified, but should be represented by a null character.

The date format follows the pattern:

DateSeparator[0] DateComponent1 DateSeparator[1] DateComponent2 DateSeparator[2] DateComponent3 DateSeparator[3]

where the ordering of date components is determined by the locale's date format setting.

The time format follows the pattern:

TimeSeparator[0] Hours TimeSeparator[1] Minutes TimeSeparator[2] Seconds TimeSeparator[3]

If the time includes a microseconds component, the third separator should occur after the microseconds, and the seconds and microseconds should be separated by the decimal separator. When formatting a two component time, the following rules apply:

if the time consists of hours and minutes, the third time delimiter should be omitted

if the time consists of minutes and seconds, the second time delimiter should be omitted

Parameters

TDes &aDes

Descriptor, which, on return contains the formatted date/time string.

const TDesC &aFormat

Format string which determines the format of the date and time.

const TLocale &aLocale

Specific locale which formatting will be based on.

Leave codes

KErrOverflow

The date/time string is too long for the descriptor aDes.

KErrGeneral

A formatting error has occurred.


RoundUpToNextMinute()

IMPORT_C void RoundUpToNextMinute();

Description

Rounds this TTime up to the next minute.

Both the seconds and microseconds components are set to zero.


Parse()

IMPORT_C TInt Parse(const TDesC &aDes, TInt aCenturyOffset=0);

Description

Parses a descriptor containing either or both a date and time, and sets this TTime to the value of the parsed descriptor.

The descriptor may contain the date only, the time only, the date followed by the time, or the time followed by the date. When both the date and time are specified in the descriptor, they should be separated using one or more space characters.

Leading zeros and spaces preceding any time or date components are discarded.

Dates may be specified either with all three components (day, month and year), or with just two components; for example month and day. The date suffix ("st" "nd" "rd" or "th") may not be included in the descriptor.

The date and its components may take different forms:

1. The month may be represented by text or by numbers.

2 European (DD/MM/YYYY), American (MM/DD/YYYY) and Japanese (YYYY/MM/DD) date formats are supported. An exception to this ordering of date components occurs when European or American formatting is used and the month is represented by text. In this case, the month may be positioned in either the first or second field. When using Japanese date format, the month, whether text or numbers, must always be the second field.

3. The year may be two or four digits. When the year is a two digit number, (e.g. 97 rather than 1997), to resolve any confusion as to which century the year falls in, the second argument determines the century. For example, if the current year is 1997, a value for aCenturyOffset of 20 means that any two digit year will resolve to a year in the range 1920 to 2019. In this case, two digit years between 00 and 19 inclusive refer to the years between 2000 and 2019 and two digit years between 20 and 99 inclusive refer to the years between 1920 and 1999. By default, two digit years are in the current century (aCenturyOffset = 0).

4. Any of the following characters may be used as the date separator: /(slash)

If a colon or a dot has been specified in TLocale as the date separator character, neither may be used as date separators in this function.

If specified, the time must include the hour, but both minutes and seconds, or seconds alone may be omitted.

The time and its components may take different forms:

1. An am/pm time suffix may be appended to the time. If 24 hour clock format is in use, this text will be ignored.

2. The am/pm suffix may be abbreviated to "a" or "p".

3. Any of the following characters may be used as the time separator: :(colon) .(dot) or either of the time separator characters specified in TLocale::SetDateSeparator() (at index 1 or 2). Other characters are illegal.

When a character can be interpreted as either a date or time separator character, this function will interpret it as a date separator.

Look out for cases in which wrongly interpreting the contents of a descriptor, based on the interpretation of separator characters, causes an error. For example, trying to interpret "5.6.1996" as a time is invalid and will return an error of -2 because 1,996 seconds is out of range.

Notes:

1. The entire content of the descriptor must be valid and syntactically correct, or an error will be returned and the parse will fail. So, excepting whitespace, which is discarded, any trailing characters within the descriptor which do not form part of the date or time are illegal.

2. If no time is specified in the descriptor, the hours, minutes and seconds of this TTime are all set to zero, corresponding to midnight at the start of the day specified in the date. If no date is specified, each of this TTime's date components are set to zero.

Parameters

const TDesC &aDes

Descriptor containing any combination of date and time as text.

TInt aCenturyOffset

Offset between zero (the default) and 99. Allows a flexible interpretation of the century for two digit year values. If less than zero, or greater than 99, a panic occurs.

Return value

TInt

If equal to or greater than zero, the function completed successfully. EParseDatePresent and/or EParseTimePresent indicate whether either or both of the date or time are present. If less than zero, an error code. KErrGeneral indicates that the time or date value is out of range, e.g. if the hour is greater than 23 or if the minute is greater than 59. KErrNotSupported indicates that a two field date has been entered. KErrArgument indicates that the descriptor was syntactically incorrect. If the function fails, this TTime object remains unchanged.


operator+()

IMPORT_C TTime operator+(TTimeIntervalYears aYear) const;

Description

Adds a time interval to this TTime, returning the result as a TTime.

Note that in a leap year, when adding one year to the 29th February, the result is the 28th February in the following year.

Note also that this TTime object is not changed.

Parameters

TTimeIntervalYears aYear

A time interval in years. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to add more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator+()

IMPORT_C TTime operator+(TTimeIntervalMonths aMonth) const;

Description

Adds a time interval to this TTime, returning the result as a TTime.

Note that when adding one month to the last day in the month, if the following month is shorter, the result is the last day in the following month. For example, when adding one month to 31st August, the result is the 30th September.

Note also that this TTime object is not changed.

Parameters

TTimeIntervalMonths aMonth

A time interval in months. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to add more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator+()

IMPORT_C TTime operator+(TTimeIntervalDays aDay) const;

Description

Adds a time interval to this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalDays aDay

A time interval in days. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to add more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator+()

IMPORT_C TTime operator+(TTimeIntervalHours aHour) const;

Description

Adds a time interval to this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalHours aHour

A time interval in hours. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to add more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator+()

IMPORT_C TTime operator+(TTimeIntervalMinutes aMinute) const;

Description

Adds a time interval to this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalMinutes aMinute

A time interval in minutes. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to add more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator+()

IMPORT_C TTime operator+(TTimeIntervalSeconds aSecond) const;

Description

Adds a time interval to this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalSeconds aSecond

A time interval in seconds. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to add more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator+()

IMPORT_C TTime operator+(TTimeIntervalMicroSeconds aMicroSecond) const;

Description

Adds a time interval to this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalMicroSeconds aMicroSecond

A time interval in microseconds.

Return value

TTime

The new time.


operator+()

IMPORT_C TTime operator+(TTimeIntervalMicroSeconds32 aMicroSecond) const;

Description

Adds a time interval to this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalMicroSeconds32 aMicroSecond

A time interval in microseconds. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to add more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator-()

IMPORT_C TTime operator-(TTimeIntervalYears aYear) const;

Description

Substracts a time interval from this TTime, returning the result as a TTime.

Note that in a leap year, when subtracting one year from the 29th February, the result is 28th February in the preceding year.

Note also that this TTime object is not changed.

Parameters

TTimeIntervalYears aYear

A time interval in years. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to subtract more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator-()

IMPORT_C TTime operator-(TTimeIntervalMonths aMonth) const;

Description

Substracts a time interval from this TTime, returning the result as a TTime.

Note that when subtracting one month from the last day in the month, if the preceding month is shorter, the result is the last day in the preceding month. For example, when subtracting 1 month from 31st October, the result is the 30th September.

Note also that this TTime object is not changed.

Parameters

TTimeIntervalMonths aMonth

A time interval in months. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to subtract more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator-()

IMPORT_C TTime operator-(TTimeIntervalDays aDay) const;

Description

Substracts a time interval from this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalDays aDay

A time interval in days. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to subtract more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator-()

IMPORT_C TTime operator-(TTimeIntervalHours aHour) const;

Description

Substracts a time interval from this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalHours aHour

A time interval in hours. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to subtract more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator-()

IMPORT_C TTime operator-(TTimeIntervalMinutes aMinute) const;

Description

Substracts a time interval from this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalMinutes aMinute

A time interval in minutes. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to subtract more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator-()

IMPORT_C TTime operator-(TTimeIntervalSeconds aSecond) const;

Description

Substracts a time interval from this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalSeconds aSecond

A time interval in seconds. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to subtract more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator-()

IMPORT_C TTime operator-(TTimeIntervalMicroSeconds aMicroSecond) const;

Description

Substracts a time interval from this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalMicroSeconds aMicroSecond

A time interval in microseconds.

Return value

TTime

The new time.


operator-()

IMPORT_C TTime operator-(TTimeIntervalMicroSeconds32 aMicroSecond) const;

Description

Substracts a time interval from this TTime, returning the result as a TTime.

Note that this TTime object is not changed.

Parameters

TTimeIntervalMicroSeconds32 aMicroSecond

A time interval in microseconds. The argument is stored as a 32 bit signed integer. The maximum value which it can represent is 2147483647. Any attempt to subtract more than this amount will produce incorrect results.

Return value

TTime

The new time.


operator+=()

IMPORT_C TTime &operator+=(TTimeIntervalYears aYear);

Description

Adds a time interval to this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalYears aYear

A time interval in years.

Return value

TTime &

A reference to this TTime.


operator+=()

IMPORT_C TTime &operator+=(TTimeIntervalMonths aMonth);

Description

Adds a time interval to this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalMonths aMonth

A time interval in months.

Return value

TTime &

A reference to this TTime.


operator+=()

IMPORT_C TTime &operator+=(TTimeIntervalDays aDay);

Description

Adds a time interval to this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalDays aDay

A time interval in days.

Return value

TTime &

A reference to this TTime.


operator+=()

IMPORT_C TTime &operator+=(TTimeIntervalHours aHour);

Description

Adds a time interval to this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalHours aHour

A time interval in hours.

Return value

TTime &

A reference to this TTime.


operator+=()

IMPORT_C TTime &operator+=(TTimeIntervalMinutes aMinute);

Description

Adds a time interval to this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalMinutes aMinute

A time interval in minutes.

Return value

TTime &

A reference to this TTime.


operator+=()

IMPORT_C TTime &operator+=(TTimeIntervalSeconds aSecond);

Description

Adds a time interval to this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalSeconds aSecond

A time interval in seconds.

Return value

TTime &

A reference to this TTime.


operator+=()

IMPORT_C TTime &operator+=(TTimeIntervalMicroSeconds aMicroSecond);

Description

Adds a time interval to this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalMicroSeconds aMicroSecond

A time interval in microseconds.

Return value

TTime &

A reference to this TTime.


operator+=()

IMPORT_C TTime &operator+=(TTimeIntervalMicroSeconds32 aMicroSecond);

Description

Adds a time interval to this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalMicroSeconds32 aMicroSecond

A time interval in microseconds, as a 32-bit integer.

Return value

TTime &

A reference to this TTime.


operator-=()

IMPORT_C TTime &operator-=(TTimeIntervalYears aYear);

Description

Subtracts a time interval from this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalYears aYear

A time interval in years.

Return value

TTime &

A reference to this TTime.


operator-=()

IMPORT_C TTime &operator-=(TTimeIntervalMonths aMonth);

Description

Subtracts a time interval from this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalMonths aMonth

A time interval in months.

Return value

TTime &

A reference to this TTime.


operator-=()

IMPORT_C TTime &operator-=(TTimeIntervalDays aDay);

Description

Subtracts a time interval from this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalDays aDay

A time interval in days.

Return value

TTime &

A reference to this TTime.


operator-=()

IMPORT_C TTime &operator-=(TTimeIntervalHours aHour);

Description

Subtracts a time interval from this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalHours aHour

A time interval in hours.

Return value

TTime &

A reference to this TTime.


operator-=()

IMPORT_C TTime &operator-=(TTimeIntervalMinutes aMinute);

Description

Subtracts a time interval from this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalMinutes aMinute

A time interval in minutes.

Return value

TTime &

A reference to this TTime.


operator-=()

IMPORT_C TTime &operator-=(TTimeIntervalSeconds aSecond);

Description

Subtracts a time interval from this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalSeconds aSecond

A time interval in seconds.

Return value

TTime &

A reference to this TTime.


operator-=()

IMPORT_C TTime &operator-=(TTimeIntervalMicroSeconds aMicroSecond);

Description

Subtracts a time interval from this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalMicroSeconds aMicroSecond

A time interval in microseconds.

Return value

TTime &

A reference to this TTime.


operator-=()

IMPORT_C TTime &operator-=(TTimeIntervalMicroSeconds32 aMicroSecond);

Description

Subtracts a time interval from this TTime, returning a reference to this TTime.

Parameters

TTimeIntervalMicroSeconds32 aMicroSecond

A time interval in microseconds, as a 32-bit integer.

Return value

TTime &

A reference to this TTime.


operator==()

inline TBool operator==(TTime aTime) const;

Description

Tests whether two date/times are equal.

Parameters

TTime aTime

The time to be compared with this TTime.

Return value

TBool

True if the two TTimes are equal. False if not.


operator!=()

inline TBool operator!=(TTime aTime) const;

Description

Tests whether two date/times are not equal.

Parameters

TTime aTime

The date/time to be compared with this TTime.

Return value

TBool

True if the two TTimes are different. False if the same.


operator>=()

inline TBool operator>=(TTime aTime) const;

Description

Tests whether this date/time is later than or the same as the specified date/time.

Parameters

TTime aTime

The date/time to be compared with this date/time.

Return value

TBool

True if this date/time is later than or the same as the specified date/time. False otherwise.


operator<=()

inline TBool operator<=(TTime aTime) const;

Description

Tests whether this date/time is earlier than or the same as the specified date/time.

Parameters

TTime aTime

The date/time to be compared with this date/time.

Return value

TBool

True if this date/time is earlier than or the same as the specified date/time. False otherwise.


operator>()

inline TBool operator>(TTime aTime) const;

Description

Tests whether this date/time is later than the specified date/time.

Parameters

TTime aTime

The date/time to be compared with this date/time.

Return value

TBool

True if this date/time is later than the specified date/time. False otherwise.


operator<()

inline TBool operator<(TTime aTime) const;

Description

Tests whether this date/time is earlier than the specified date/time.

Parameters

TTime aTime

The date/time to be compared with this date/time.

Return value

TBool

True if this date/time is earlier than the specified date/time. False otherwise.


Int64()

inline const TInt64 &Int64() const;

Description

Gets the 64 bit integer representation of this TTime obect.

Return value

const TInt64 &

The 64 bit integer representation.