AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Datumsstring formatiert nach TDateTime

Ein Thema von SMALLID · begonnen am 7. Mai 2007 · letzter Beitrag vom 7. Mai 2007
Antwort Antwort
SMALLID

Registriert seit: 10. Aug 2004
78 Beiträge
 
#1

Re: Datumsstring formatiert nach TDateTime

  Alt 7. Mai 2007, 16:09
Hallo marabu,

Danke! Ich habe mir mit Hilfe dieses Threads was basteln können:

Bsp.-string siehe oben: '[23/May/2006:19:22:45 '

Delphi-Quellcode:
function ParseDlDateTimeString(s : string) : TDateTime;
var fs : TFormatSettings;
    sl : TStringList;
    i : integer;
    date, time : string;
begin
  //s := '[23/Apr/2004:20:08:33';
  date := copy(s, 2, 11);
  //ShowMessage(date);
  time := copy(s, 14, 8);
  //ShowMessage(time);

  GetLocaleFormatSettings(GetUserDefaultLCID, fs);
  with fs do
  begin
    fs.ShortMonthNames[1] := 'Jan';
    fs.ShortMonthNames[2] := 'Feb';
    fs.ShortMonthNames[3] := 'Mar';
    fs.ShortMonthNames[4] := 'Apr';
    fs.ShortMonthNames[5] := 'May';
    fs.ShortMonthNames[6] := 'Jun';
    fs.ShortMonthNames[7] := 'Jul';
    fs.ShortMonthNames[8] := 'Aug';
    fs.ShortMonthNames[9] := 'Sep';
    fs.ShortMonthNames[10] := 'Oct';
    fs.ShortMonthNames[11] := 'Nov';
    fs.ShortMonthNames[12] := 'Dec';

    sl := TStringList.Create;
    sl.Delimiter := '/';
    sl.DelimitedText := date;
    for i := 1 to 12 do
      if ShortMonthNames[i] = sl[1] then begin
        if i < 10 then
          sl[1] := '0' + IntToStr(i)
        else
          sl[1] := IntToStr(i);
        Break;
      end;
    date := Format('%s/%s/%s', [sl[0], sl[1], sl[2]]);
    sl.Free;

    fs.DateSeparator := '/';
    fs.ShortDateFormat := 'dd/mm/yyyy';
    fs.ShortTimeFormat := 'hh:mm:ss';
  end;
  result := StrToDate(date, fs) + StrToTime(time, fs);
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~
Muh
  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 05:47 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 by Thomas Breitkreuz