Jump to content

Recommended Posts

I dont know if help you, I did some test using "FormatSettings" creating and some countries.

and was possible use anothers chars and get all milliseconds as expected

procedure TForm1.Button1Click(Sender: TObject);
var
  LocalName: string;
  FS       : TFormatSettings;
  LChar    : char;
  LDateStr : string;
begin
  LocalName := ListBox1.Items[ListBox1.ItemIndex];
  //
  FS := TFormatSettings.Create(LocalName);
  //
  Memo1.Text := 'Before: [' + FS.DecimalSeparator + ']';
  Memo1.Lines.Add('Before: [' + FS.ShortDateFormat + ']');
  Memo1.Lines.Add('Before: [' + FS.LongTimeFormat + ']');
  //
  LChar := ListBox2.Items[ListBox2.ItemIndex][1]; // ,  .  !  @  *  $  &   ...
  //
  FS.LongTimeFormat := format('hh:nn:ss%szzz', [LChar]);
  //
  Memo1.Lines.Add('After: [' + FS.DecimalSeparator + ']');
  Memo1.Lines.Add('After: [' + FS.ShortDateFormat + ']');
  Memo1.Lines.Add('After: [' + FS.LongTimeFormat + ']');
  //
  if LocalName.Contains('de-DE') or LocalName.Contains('ru-RU') or LocalName.Contains('be-BE') then
    LDateStr := '19.04.2023' + ' 11:59:10,238' // '.' = 11:59:00!000
  else
    if LocalName.Contains('zh-CN') then
      LDateStr := '2023/04/19' + ' 11:59:10.238' // comma = Error
    else
      if LocalName.Contains('fr-FR') or LocalName.Contains('pt-BR') then
        LDateStr := '19/04/2023' + ' 11:59:10,238' // "point" = FR 11:59:00.000 / BR "point" = Error
      else
        LDateStr := '04/19/2023' + ' 11:59:10.238'; // comma = Error
  //
  Memo1.Lines.Add(StrToDateTime(LDateStr, FS).ToString(FS));
end;

 

 

 

prjFormatDateTime_tests_8XkKPzsdCd.gif

Share this post


Link to post
1 hour ago, programmerdelphi2k said:

I dont know if help you, I did some test using "FormatSettings" creating and some countries.

 and was possible use anothers chars and get all milliseconds as expected

Not really. I can't modify the DAC source, neither do I want to. 😕

 

 

Share this post


Link to post

just not possible verify the date and convert to format expected in each Country-Format, or use a universal format like ISO, before any works?

Edited by programmerdelphi2k

Share this post


Link to post
3 minutes ago, programmerdelphi2k said:

just not possible verify the date and convert to format expected in each Country-Format, or use a universal format like UTC, before any works?

I'm sure we could find a workaround but why not just fix Delphi?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×