Autor Beitrag
Hendrik
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324



BeitragVerfasst: Sa 18.01.03 12:30 
Hallo

Wie kann ich einer Variabelen vom Typ TTime ein paar Sekunden hinzufügen?
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Sa 18.01.03 12:46 
ausblenden Quelltext
1:
t := t + EncodeTime(0, 0, sec, 0);					

Eine andere Möglichkeit:
ausblenden Quelltext
1:
t := t + Sec / SecsPerDay;					

_________________
Ist Zeit wirklich Geld?
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 18.01.03 12:50 
mit timetostr kannst du deine Zeitvariable in einen String umwandeln...
dann kannst du davon einfach die letzten beiden stellen auslesen und si um eins erhöhen..
dann wieder mit strtotime zurückumwandeln in deine zeitvar...

muisst darauf aufpassen, wenn die sekunden >60 sind

Fiji-Fighter
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 18.01.03 12:51 
ich bin immer zu langsam.. :evil:

deine MEthode ist wahrscheinlich besser, aber meine dürfte auch funktionieren...

Fiji-Fighter
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Sa 18.01.03 12:53 
Funktionieren schon, nur ist sie
1. viel zu langsam, da Umwandung in String, Stringbearbeitung, Umwandeln in TDateTime
2. sehr umständlich zu programmieren, womit sich sehr schnell Fehler einschleichen.

_________________
Ist Zeit wirklich Geld?
Wolff68
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 302
Erhaltene Danke: 1

WinXP home
D6 Prof
BeitragVerfasst: Sa 18.01.03 12:55 
Kleines Beispiel-Prog:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var
  Zeit : TTime;
begin
  Zeit := Now;
  Edit1.Text := TimeToStr(Zeit);
  Zeit := Zeit + EncodeTime(0,0,1,0);
  Edit2.Text := TimeToStr(Zeit);
  Zeit := Zeit + 0.0000115740740740741;
  // = 1Tag / 24Std / 60Min / 60Sek
  Edit3.Text := TimeToStr(Zeit);
end;


Wobei ich das mit dem EncodeTime bevorzugen würde, weil Du sonst erstens nicht mehr weist was 0,0000115... bedeutet, und zweitens eventuell Rundungsfehler auftreten.
Das mit dem Zerlegen in String und wieder setzen als Zeit ist umständlich und Fehleranfälliger.

Ok, war auch zu langsam... :)

_________________
"Der Mensch ist nicht was er sich vorstellt oder wünscht zu sein, sondern das was andere in ihm sehen."
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 18.01.03 12:55 
hab ja schon gesagt, dass deine Methode besser ist...
Hendrik Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324



BeitragVerfasst: Sa 18.01.03 16:38 
Dangö! Ich werds mal ausprobiern!