0

Hello again, pretty simple question this time I would think.

What I'm wanting is to be able to add 5 minutes onto a ttime variable. As what I'm trying to acheive is a queue system. (Time + QueueTime) and (QueueTime := QueueTime + ProductTime)

However I get the basics, just can't seem to find a simple way to add a time of my choice onto an existing time (14:23 + 00:07) if you know what I mean.

Thanks,

2
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by DelphiGuy
0

I'm not to sure about TTime but I've used TDateTime before and maybe you can do something like this:

var
  Time : TTime;
begin
  Time := Now;
  Time := Time + EncodeTime(0, 5, 0, 0); //Adds 5 minutes to Time
  ShowMessage(TimeToStr(Time));
end;

See EncodeTime: http://www.delphibasics.co.uk/RTL.asp?Name=EncodeTime
I think this is what your trying to achieve, the problem with incrementing time is the format and the way it works, you need to increment time with time variables as opposed to standard integers.

Edited by DelphiGuy: n/a

0

Thanks, has now been solved however...

If ProductSelect.Text = 'Toast ' then
         begin
        time_queue := (time_queue + ((1 / 24 / 60) * 5));
         Edit2.Text := TimetoStr(now + time_queue);
         end;

THIS WORKS, yet when I want to take the 5 minutes off of the time_queue it does not work. Any ideas?

If StringGrid1.Cells[1,1] = 'Toast ' then
         begin
        time_queue := (time_queue - ((1 / 24 / 60) * 5));
         end;

Edited by garden4ork: n/a

0

Well you could just do:

If StringGrid1.Cells[1,1] = 'Toast ' then
begin
  time_queue := time_queue - EncodeTime(0, 5, 0, 0);
end;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.