Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
Delphi 12 Athens
|
AW: Bis = 24:00:00
12. Apr 2023, 19:09
Also IsValidTime scheint damit kein Problem zu haben
IsValidTime und ISO8601ToDate sind scheinbar die Einzigen?
Hab mal ganz böse rumgepfuscht, aber z.B. StrToDateTime mag es nicht.
Delphi-Quellcode:
uses DateUtils, StrUtils;
procedure TForm24.FormCreate(Sender: TObject);
begin
// FormatDateTime('dd.mm.yyyy hh:mm:ss', DE) = DateTimeToStr(T, DE) incl. 00:00:00
var EN := TFormatSettings.Create(' en-US');
var DE := TFormatSettings.Create(' de-DE');
var ShowString := procedure(S: string; FS: TFormatSettings)
begin
try
var T := StrToDateTime(S, FS);
Memo1.Lines.Add(Format(' %s = %.4n = %s = %s', [S, T, FormatDateTime(' dd.mm.yyyy hh:mm:ss', T, DE), DateTimeToStr(T, EN)]));
except
on E: Exception do
Memo1.Lines.Add(Format(' %s = %s' , [S, E.ClassName]));
end;
end;
// {} = EConvertError
Memo1.Lines.Add(' ');
{}ShowString(' 4/12/2023 00:00:00 AM', EN);
{}ShowString(' 4/12/2023 00:01:00 AM', EN);
ShowString(' 4/12/2023 01:00:00 AM', EN);
ShowString(' 4/12/2023 02:00:00 AM', EN);
ShowString(' 4/12/2023 11:00:00 AM', EN);
ShowString(' 4/12/2023 12:00:00 AM', EN);
ShowString(' 4/12/2023 12:01:00 AM', EN);
{}ShowString(' 4/12/2023 00:00:00 PM', EN);
{}ShowString(' 4/12/2023 00:01:00 PM', EN);
ShowString(' 4/12/2023 01:00:00 PM', EN);
ShowString(' 4/12/2023 02:00:00 PM', EN);
ShowString(' 4/12/2023 11:00:00 PM', EN);
ShowString(' 4/12/2023 12:00:00 PM', EN);
ShowString(' 4/12/2023 12:01:00 PM', EN);
Memo1.Lines.Add(' ');
ShowString(' 12.04.2023 00:00:00', DE);
ShowString(' 12.04.2023 00:01:00', DE);
ShowString(' 12.04.2023 01:00:00', DE);
ShowString(' 12.04.2023 02:00:00', DE);
ShowString(' 12.04.2023 11:00:00', DE);
ShowString(' 12.04.2023 12:00:00', DE);
ShowString(' 12.04.2023 12:01:00', DE);
ShowString(' 12.04.2023 13:00:00', DE);
ShowString(' 12.04.2023 14:00:00', DE);
ShowString(' 12.04.2023 23:00:00', DE);
{}ShowString(' 12.04.2023 24:00:00', DE);
{}ShowString(' 12.04.2023 24:01:00', DE);
var ShowDate := procedure(T: TDateTime)
begin
Memo1.Lines.Add(IfThen(T < 0, ' ', ' +') + Format(' %.4n = ', [T]) + FormatDateTime(' dd.mm.yyyy hh:mm:ss', T, DE) + ' = ' + DateTimeToStr(T, EN));
end;
Memo1.Lines.Add(' ');
ShowDate(45028.0);
ShowDate(45028.5);
ShowDate(45029.0);
Memo1.Lines.Add(' ');
ShowDate(0);
ShowDate(0 + 1/MinsPerDay);
ShowDate(2.75);
ShowDate(-1.25);
ShowDate(35065);
ShowDate(35065 + 1/MinsPerDay);
Memo1.Lines.Add(' ');
ShowDate(1.75);
ShowDate(IncDay(1.75, -2));
end;
Code:
4/12/2023 00:00:00 AM = EConvertError
4/12/2023 00:01:00 AM = EConvertError
4/12/2023 01:00:00 AM = 45.028,0417 = 12.04.2023 01:00:00 = 4/12/2023 1:00:00 AM
4/12/2023 02:00:00 AM = 45.028,0833 = 12.04.2023 02:00:00 = 4/12/2023 2:00:00 AM
4/12/2023 11:00:00 AM = 45.028,4583 = 12.04.2023 11:00:00 = 4/12/2023 11:00:00 AM
4/12/2023 12:00:00 AM = 45.028,0000 = 12.04.2023 00:00:00 = 4/12/2023
4/12/2023 12:01:00 AM = 45.028,0007 = 12.04.2023 00:01:00 = 4/12/2023 12:01:00 AM
4/12/2023 00:00:00 PM = EConvertError
4/12/2023 00:01:00 PM = EConvertError
4/12/2023 01:00:00 PM = 45.028,5417 = 12.04.2023 13:00:00 = 4/12/2023 1:00:00 PM
4/12/2023 02:00:00 PM = 45.028,5833 = 12.04.2023 14:00:00 = 4/12/2023 2:00:00 PM
4/12/2023 11:00:00 PM = 45.028,9583 = 12.04.2023 23:00:00 = 4/12/2023 11:00:00 PM
4/12/2023 12:00:00 PM = 45.028,5000 = 12.04.2023 12:00:00 = 4/12/2023 12:00:00 PM
4/12/2023 12:01:00 PM = 45.028,5007 = 12.04.2023 12:01:00 = 4/12/2023 12:01:00 PM
12.04.2023 00:00:00 = 45.028,0000 = 12.04.2023 00:00:00 = 4/12/2023
12.04.2023 00:01:00 = 45.028,0007 = 12.04.2023 00:01:00 = 4/12/2023 12:01:00 AM
12.04.2023 01:00:00 = 45.028,0417 = 12.04.2023 01:00:00 = 4/12/2023 1:00:00 AM
12.04.2023 02:00:00 = 45.028,0833 = 12.04.2023 02:00:00 = 4/12/2023 2:00:00 AM
12.04.2023 11:00:00 = 45.028,4583 = 12.04.2023 11:00:00 = 4/12/2023 11:00:00 AM
12.04.2023 12:00:00 = 45.028,5000 = 12.04.2023 12:00:00 = 4/12/2023 12:00:00 PM
12.04.2023 12:01:00 = 45.028,5007 = 12.04.2023 12:01:00 = 4/12/2023 12:01:00 PM
12.04.2023 13:00:00 = 45.028,5417 = 12.04.2023 13:00:00 = 4/12/2023 1:00:00 PM
12.04.2023 14:00:00 = 45.028,5833 = 12.04.2023 14:00:00 = 4/12/2023 2:00:00 PM
12.04.2023 23:00:00 = 45.028,9583 = 12.04.2023 23:00:00 = 4/12/2023 11:00:00 PM
12.04.2023 24:00:00 = EConvertError
12.04.2023 24:01:00 = EConvertError
+45.028,0000 = 12.04.2023 00:00:00 = 4/12/2023
+45.028,5000 = 12.04.2023 12:00:00 = 4/12/2023 12:00:00 PM
+45.029,0000 = 13.04.2023 00:00:00 = 4/13/2023
+0,0000 = 30.12.1899 00:00:00 = 12/30/1899
+0,0007 = 30.12.1899 00:01:00 = 12/30/1899 12:01:00 AM
+2,7500 = 01.01.1900 18:00:00 = 1/1/1900 6:00:00 PM
-1,2500 = 29.12.1899 06:00:00 = 12/29/1899 6:00:00 AM
+35.065,0000 = 01.01.1996 00:00:00 = 1/1/1996
+35.065,0007 = 01.01.1996 00:01:00 = 1/1/1996 12:01:00 AM
+1,7500 = 31.12.1899 18:00:00 = 12/31/1899 6:00:00 PM
-1,7500 = 29.12.1899 18:00:00 = 12/29/1899 6:00:00 PM
$2B or not $2B
Geändert von himitsu (12. Apr 2023 um 19:18 Uhr)
|