_LIT String with Format

Login to reply to this topic.
Tue, 2005-05-03 08:37
Joined: 2005-02-08
Forum posts: 42
Code:
TBuf<30> dateString;

_LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");

(*iDirList)[i].iModified.FormatL(dateString,KDateString);

above is code from FilelistExample from forum nokia to display date time that last modify of a file

in c++ and symbian use a % - symbol to insert some value from variable
is it right?
and
Code:
what is %D %M %Y
%/0
%1%/1
%2%/2
%3%/3

%-B

%:0
%J

%:1
%T

%:2
%S

%:3
%+B

Shocked

Tue, 2005-05-03 08:48
Joined: 2004-07-28
Forum posts: 1379
_LIT String with Format
Read the manual for TTime::FormatL:

Code:
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 — 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.



didster

Tue, 2005-05-03 09:14
Joined: 2005-02-08
Forum posts: 42
That a very kind of you
Thank you, didster
Cheezy
  • Login to reply to this topic.