A TFormatSettings argument can be provided to the TDate and
TDateTime string formatting functions in System.SysUtils.
If a TFormatSettings argument is not provided, then the global
TFormatSettings will be used by default.
Relying on the global TFormatSettings is problematic because it is populated with
system default values from the OS, leading to different behavior on different machines.
Functions that accept a TFormatSettings argument include:
System.SysUtils.DateToStrSystem.SysUtils.DateTimeToStrSystem.SysUtils.StrToDateSystem.SysUtils.StrToDateDefSystem.SysUtils.TryStrToDateSystem.SysUtils.StrToDateTimeSystem.SysUtils.StrToDateTimeDefSystem.SysUtils.TryStrToDateTime
Create a local TFormatSettings instance, configure it with the desired date
formatting properties, and pass it in as the last parameter of the formatting routine.
procedure PrintCurrentTime; begin Writeln(DateToStr(Now)); end;
procedure PrintCurrentTime; var LocalFormatSettings: TFormatSettings; begin LocalFormatSettings := TFormatSettings.Create; LocalFormatSettings.ShortDateFormat := 'dd/mm/yyyy'; Writeln(DateToStr(Now), LocalFormatSettings); end;