Format the date by capitalizing the first letter of the month
I know it has several other date formatting topics plus I didn't find one with my doubt...
According to the documentation of the Delphi the date is formatted according to the table below.
d ------------|Exibe o dia como um número sem um zero inicial (1-31).
dd -----------|Exibe o dia como um número com um zero à esquerda (01-31).
ddd ----------|Exibe o dia como uma abreviação (Sun-Sat) usando as strings dadas pela variável global ShortDayNames .
dddd ---------|Exibe o dia como um nome completo (domingo a sábado) usando as strings dadas pela variável global LongDayNames .
ddddd --------|Exibe a data usando o formato fornecido pela variável global ShortDateFormat .
ddddd --------|Exibe a data usando o formato fornecido pela variável global LongDateFormat.
m ------------|Exibe o mês como um número sem um zero inicial (1-12). Se o especificador m segue imediatamente um especificador h ou hh, o minuto em vez do mês é exibido.
mm -----------|Exibe o mês como um número com um zero inicial (01-12). Se o especificador mm seguir imediatamente um especificador h ou hh, será exibido o minuto em vez do mês.
mmm ----------|Exibe o mês como uma abreviação (Jan-Dec) usando as strings dadas pela variável global ShortMonthNames .
mmmm ---------|Exibe o mês como um nome completo (janeiro-dezembro) usando as strings dadas pela variável global LongMonthNames .
yy -----------|Exibe o ano como um número de dois dígitos (00 a 99).
yyyy ---------|Exibe o ano como um número de quatro dígitos (0000-9999).
'xx' / "xx" --|Os caracteres entre aspas simples ou duplas são exibidos dessa forma e não afetam a formatação.
Example of use to format the date:
procedure TForm1.Button1Click(Sender: TObject);
var S : string;
begin
S := SysUtils.FormatDateTime('dd "de " mmmm "de " yyyy, Now());
Label1.Caption := S;
end;
How to see does not have an option to exit the month with the first letter in capital would you have another alternative to do that?
2 answers
I did so and it worked out.
Follows the code.
procedure TForm1.Button1Click(Sender: TObject);
var
S : string;
Format: TFormatSettings;
begin
if MonthOf(Now) = 1 then Format.LongMonthNames[1] := 'Janeiro' else
if MonthOf(Now) = 2 then Format.LongMonthNames[2] := 'Fevereiro' else
if MonthOf(Now) = 3 then Format.LongMonthNames[3] := 'Março' else
if MonthOf(Now) = 4 then Format.LongMonthNames[4] := 'Abril' else
if MonthOf(Now) = 5 then Format.LongMonthNames[5] := 'Maio' else
if MonthOf(Now) = 6 then Format.LongMonthNames[6] := 'Junho' else
if MonthOf(Now) = 7 then Format.LongMonthNames[7] := 'Julho' else
if MonthOf(Now) = 8 then Format.LongMonthNames[8] := 'Agosto' else
if MonthOf(Now) = 9 then Format.LongMonthNames[9] := 'Setembro' else
if MonthOf(Now) = 10 then Format.LongMonthNames[10] := 'Otubro' else
if MonthOf(Now) = 11 then Format.LongMonthNames[11] := 'Novenbro' else
if MonthOf(Now) = 12 then Format.LongMonthNames[12] := 'Dezembro';
S := SysUtils.FormatDateTime('dd "de " mmmm "de " yyyy, Now());
end;
So it works well and only the month is capitalized.
Test ai if it works out from a +1.
The simplest is to convert the letter after assignment to the variable:
procedure TForm1.Button1Click(Sender: TObject);
var
s : string;
begin
s := FormatDateTime('dd" de "mmmm" de "yyyy', date());
s[7] := UpCase(s[7]);
ShowMessage(s);
end;