Paul H 0 Posted June 9 I need a millisecond counter (NOT a timer) that can operate on Hours/Minutes/Seconds with an upper limit of > 1000 hr. Delphi's TTime and TTimeStamp aren't what I need - does anyone know of anyhing suitable? Without too much effort I could probably put something together using a record helper with a simple Cardinal type, but if something already exists I don't want to reinvent the wheel. Share this post Link to post
DelphiUdIT 243 Posted June 9 (edited) 37 minutes ago, Paul H said: I need a millisecond counter (NOT a timer) that can operate on Hours/Minutes/Seconds with an upper limit of > 1000 hr. Delphi's TTime and TTimeStamp aren't what I need - does anyone know of anyhing suitable? Without too much effort I could probably put something together using a record helper with a simple Cardinal type, but if something already exists I don't want to reinvent the wheel. You can use from unit System.DIagnostics the TStopWatch "record": Uses System.Diagnostics; var a:TStopWatch; begin a := TStopWatch.StartNew; .... .... a.Stop; ShowMessage(a.ElapsedMilliseconds.toString); end; For better info: https://docwiki.embarcadero.com/Libraries/Athens/en/System.Diagnostics.TStopwatch P.S.: you have also the "Elapsed" property that maintain the features you required (but you can simple calculate them from "milliseconds". Edited June 9 by DelphiUdIT Share this post Link to post
FPiette 393 Posted June 9 1 hour ago, Paul H said: I need a millisecond counter (NOT a timer) that can operate on Hours/Minutes/Seconds with an upper limit of > 1000 hr. Use GetTickCount64 in the unit Winapi.Windows. It returns the number of milliSec elapsed since the computer has been powered on. Share this post Link to post
Paul H 0 Posted June 9 Thanks for both comments, but I don't need a timer, so TStopwatch or the system timer are't suitable either. I am building a time based numerical integrator, so real time is not important, I will be setting the integrator "time" manualy as needed. The Time Counter merely keeps track of where we are in the integration and provides the integration time step. Share this post Link to post
Paul H 0 Posted Monday at 10:47 AM Thanks David - I was hoping to find something with H-M-S support including setting / getting in decimals the way you can with TTime. It is probably no more than a couple of hours work to do something basic with a record helper, I just didn't want to duplicate something that already exists. Share this post Link to post
David Heffernan 2444 Posted Monday at 11:10 AM (edited) 23 minutes ago, Paul H said: Thanks David - I was hoping to find something with H-M-S support including setting / getting in decimals the way you can with TTime. It is probably no more than a couple of hours work to do something basic with a record helper, I just didn't want to duplicate something that already exists. I mean you didn't say any of this in your original post. Clearly you knew what your requirements were, but we can't read your kind! Edited Monday at 11:10 AM by David Heffernan Share this post Link to post
Paul H 0 Posted Monday at 11:15 AM I did say originally I wanted a counter with H-M-S support, which (to me at least) implies decimal input/output. Sorry if that wasn't clear to you. Share this post Link to post
David Heffernan 2444 Posted Monday at 11:23 AM 8 minutes ago, Paul H said: I did say originally I wanted a counter with H-M-S support, which (to me at least) implies decimal input/output. Sorry if that wasn't clear to you. Yes, my fault. Sorry. Share this post Link to post
DelphiUdIT 243 Posted Monday at 11:28 AM (edited) 43 minutes ago, Paul H said: Thanks David - I was hoping to find something with H-M-S support including setting / getting in decimals the way you can with TTime. It is probably no more than a couple of hours work to do something basic with a record helper, I just didn't want to duplicate something that already exists. Like I wrote, there is also Elapsed, that is based on TTimeSpawn: https://docwiki.embarcadero.com/Libraries/Sydney/en/System.TimeSpan.TTimeSpan You can use that advanced record ... Edited Monday at 11:30 AM by DelphiUdIT Share this post Link to post
Paul H 0 Posted Monday at 12:34 PM 1 hour ago, DelphiUdIT said: Like I wrote, there is also Elapsed, that is based on TTimeSpawn: https://docwiki.embarcadero.com/Libraries/Sydney/en/System.TimeSpan.TTimeSpan You can use that advanced record ... Yes, TTimeSpan on its own seems to do exactly what I need (and a lot more). Thanks. Share this post Link to post