AGB  ·  Datenschutz  ·  Impressum  







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

VarToDateTime mit englischem Datum

Ein Thema von FunThomas · begonnen am 14. Jan 2012 · letzter Beitrag vom 15. Jan 2012
 
Benutzerbild von implementation
implementation

Registriert seit: 5. Mai 2008
940 Beiträge
 
FreePascal / Lazarus
 
#3

AW: VarToDateTime mit englischem Datum

  Alt 14. Jan 2012, 21:35
Zur Not mach's so:
Delphi-Quellcode:
function ConvertDate(const str: string): TDate;
var i: byte; d, m, y: word; mn: string;
const months: array[1..12] of string = ('jan','feb','mar','apr','may',
               'jun','jul','aug','sep','oct','nov','dec');
  procedure Next;
  begin
    Inc(i);
  end;
  function GetNum: word;
  begin
    Result := 0;
    while str[i] in ['0'..'9'] do begin
      Result := Result*10 + Ord(str[i]) - Ord('0');
      Next;
    end;
  end;
  procedure SkipWhite;
  begin
    while str[i] in [#9,#32] do Next;
  end;
  function GetName: string;
  begin
    Result := '';
    while str[i] in ['a'..'z','A'..'Z'] do begin
      if str[i] in ['a'..'z'] then
        Result := Result + str[i]
      else Result := Result + Chr(Ord(str[i])-Ord('A')+Ord('a'));
      Next;
   end;
  end;
begin
  i := 1;
  d := GetNum;
  SkipWhite;
  mn := GetName;
  SkipWhite;
  y := GetNum;
  for i := 1 to 12 do
    if months[i]=mn then
      m := i;
  if not TryEncodeDate(y,m,d,result) then
    raise EConvertError.Create('Invalid date');
end;

Geändert von implementation (14. Jan 2012 um 21:56 Uhr)
  Mit Zitat antworten Zitat
 


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 19:12 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