win: fix default ShortDateFormat and LongDateFormat

(cherry picked from commit 2c81b44b1c)
This commit is contained in:
Ondrej Pokorny 2021-08-11 11:06:17 +02:00 committed by marcoonthegit
parent 9f405f0a69
commit 2be9476fbb

View File

@ -1262,6 +1262,21 @@ begin
end;
procedure GetLocaleFormatSettings(LCID: Integer; var FormatSettings: TFormatSettings);
function FixSeparator(const FromSeparator, ToSeparator: Char; const Format: string): string;
var
R: PChar;
begin
if (Format='') or (FromSeparator=ToSeparator) then
Exit(Format);
Result := Copy(Format, 1);
R := PChar(Result);
while R^<>#0 do
begin
if R^=FromSeparator then
R^:='/';
Inc(R);
end;
end;
var
HF : Shortstring;
LID : Windows.LCID;
@ -1283,8 +1298,8 @@ begin
LongDayNames[I]:=GetLocaleStr(LID,LOCALE_SDAYNAME1+Day,LongDayNames[i]);
end;
DateSeparator := GetLocaleChar(LID, LOCALE_SDATE, '/');
ShortDateFormat := GetLocaleStr(LID, LOCALE_SSHORTDATE, 'm/d/yy');
LongDateFormat := GetLocaleStr(LID, LOCALE_SLONGDATE, 'mmmm d, yyyy');
ShortDateFormat := FixSeparator(DateSeparator, '/', GetLocaleStr(LID, LOCALE_SSHORTDATE, 'm/d/yy'));
LongDateFormat := FixSeparator(DateSeparator, '/', GetLocaleStr(LID, LOCALE_SLONGDATE, 'mmmm d, yyyy'));
{ Time stuff }
TimeSeparator := GetLocaleChar(LID, LOCALE_STIME, ':');
TimeAMString := GetLocaleStr(LID, LOCALE_S1159, 'AM');