Get any time in milliseconds?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Apr 13 09:31:32 PDT 2008


"Benjamin Schulte" <Aldoric at gmx.de> wrote in message 
news:ftst9o$sql$1 at digitalmars.com...
> Hi.
> I'm currently trying to convert my application to linux.
> Now I had a counter in my application that counted in milliseconds the 
> time since the application started. I have to port this to linux.
>
> On windows I used the PerformanceCounter from the WinAPI (or the 
> GetTickCount method, if the performance-counter is not supported).
>
> Well, I would like to have it more OS-independent or at least working 
> somehow in linux.
> I tried the std.date, but actually I would have to calculate the ms-value 
> up from the splitted values (hours, days, etc). That would be kinda 
> complicated, cause there are too many special things. Like some month only 
> have 30 days, sometimes 28, etc.
> Then I found the std.c.time clock() method, but realized, that that maybe 
> wraps very early, cause one second is 1000000 and the value is stored in 
> an integer. that would mean that after ~36 minutes the timer would wrap to 
> zero (or minus something?) again. That's not helpful.
>
> So, now I'm looking for an alternate way to realize what I want. I just 
> want ANY time counter in milliseconds. I can calculate it down to any base 
> I want, but I just need a time~
>
> Thanks in advance for any help

std.date.getUTCtime() gives you I believe millisecond-precise time as a long 
(64-bit int). 





More information about the Digitalmars-d mailing list