Autor Beitrag
ByStones
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 92
Erhaltene Danke: 1

Windows XP
Delphi 2005
BeitragVerfasst: Sa 12.11.05 13:44 
Hi,

ich schreibe gerade ein Zeit mess programm. Wie kann ich die minuten aufrunden ???
Immer auf 15, 30, 45, 00 minuten ???

ByStones
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Sa 12.11.05 13:58 
ausblenden Delphi-Quelltext
1:
2:
 if (minuten > 15) and (minuten > 30) and (minuten < 45) then
  minuten := 45;


usw.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 12.11.05 14:04 
ausblenden Delphi-Quelltext (EDH)
1:
2:
3:
4:
5:
6:
7:
8:
9:
Function RoundTime(T: TTime): TTime;
var
  H,M,S,ms : Word;
begin
  DecodeTime(T, H, M, S, ms);
  M := (M div 15) * 15;
  S := 0;
  Result := EncodeTime(H, M, S, ms);
end;

Wäre die kürzere und schönere Methode.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Sa 12.11.05 14:14 
user profile iconKarlson hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
 if (minuten > 15) and (minuten > 30) and (minuten < 45) then
  minuten := 45;


usw.


Sehr redundant.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 12.11.05 22:25 
(Sehr redundant) man lernt hier nicht aus.
Aber Ich schreibe gerade ein Zeit mess programm.
Worauf es auf eine viertel Stunde nicht ankommt !?