Browse Source

win: fix default ShortDateFormat and LongDateFormat

Ondrej Pokorny 4 years ago
parent
commit
2c81b44b1c
1 changed files with 17 additions and 2 deletions
  1. 17 2
      rtl/win/sysutils.pp

+ 17 - 2
rtl/win/sysutils.pp

@@ -1197,6 +1197,21 @@ begin
 end;
 end;
 
 
 procedure GetLocaleFormatSettings(LCID: Integer; var FormatSettings: TFormatSettings);
 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
 var
   HF  : Shortstring;
   HF  : Shortstring;
   LID : Windows.LCID;
   LID : Windows.LCID;
@@ -1218,8 +1233,8 @@ begin
         LongDayNames[I]:=GetLocaleStr(LID,LOCALE_SDAYNAME1+Day,LongDayNames[i]);
         LongDayNames[I]:=GetLocaleStr(LID,LOCALE_SDAYNAME1+Day,LongDayNames[i]);
         end;
         end;
       DateSeparator := GetLocaleChar(LID, LOCALE_SDATE, '/');
       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 }
       { Time stuff }
       TimeSeparator := GetLocaleChar(LID, LOCALE_STIME, ':');
       TimeSeparator := GetLocaleChar(LID, LOCALE_STIME, ':');
       TimeAMString := GetLocaleStr(LID, LOCALE_S1159, 'AM');
       TimeAMString := GetLocaleStr(LID, LOCALE_S1159, 'AM');