AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Datumsformat (TT.MM.JJJJ) anzeigen
Thema durchsuchen
Ansicht
Themen-Optionen

Datumsformat (TT.MM.JJJJ) anzeigen

Ein Thema von TUX_der_Pinguin · begonnen am 6. Jun 2018 · letzter Beitrag vom 11. Jun 2018
Antwort Antwort
Der schöne Günther

Registriert seit: 6. Mär 2013
6.211 Beiträge
 
Delphi 10 Seattle Enterprise
 
#1

AW: Datumsformat (TT.MM.JJJJ) anzeigen

  Alt 6. Jun 2018, 11:22
Knifflige Frage.

Die paar Leute die sich im Internet die gleiche Frage gestellt haben ([1], [2]) hast du sicher auch schon gefunden. Da das Format mit 'yyyy' oder 'dd' dokumentiert und sprachunabhängig ist [3] musst du die halt durch deine eigene lokalisierte Fassung ersetzen. Beispielsweise so in der Art:
Delphi-Quellcode:
uses
   System.SysUtils,
   WinApi.Windows,
   Vcl.Dialogs;

function getShortDateFormat(): String;
const
   lcType = LOCALE_SSHORTDATE;
var
   str: String;
   bufferSize: Integer;
begin
   bufferSize := GetLocaleInfoEx(
      PChar(LOCALE_NAME_USER_DEFAULT),
      lcType,
      nil,
      0
   );
   str := String.Create(#0, bufferSize);
   Win32Check(
      GetLocaleInfoEx(
         PChar(LOCALE_NAME_USER_DEFAULT),
         lcType,
         PChar(str),
         bufferSize
      ) = bufferSize
   );
   Result := Str;
end;

procedure p();
resourcestring
   shortDay = 'T';
   shortMonth = 'M';
   shortYear = 'Y';
var
   shortDateFormat: String;
begin
   shortDateFormat :=
      getShortDateFormat()
      .Replace('d', shortDay)
      .Replace('M', shortMonth)
      .Replace('y', shortYear);
   ShowMessage(shortDateFormat);
end;

[1] http://forums.codeguru.com/showthrea...indowsversions
[2] https://stackoverflow.com/q/12591993/2298252
[3] https://technet.microsoft.com/de-de/.../dd317787.aspx

Geändert von Der schöne Günther ( 6. Jun 2018 um 11:25 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz