-
October 19th, 2009, 10:54 AM
#1
Difference between two time values
Hi, I want to get the difference between two time values expressed in HH:MM:SS:MilliSecond in all the four components of time. ie. Time1 = 12:30:45:345 , Time2= 12:45:48:400. I want the want the difference between these two values in terms of hour, minute, second and millisecond. The COleDateTime class supports only upto second and not millisecond though it has a constructor that acceps a SYSTEMTIME structure as argument. But I dont know how to get the millisecond value from COleDateTime even if I passed a SYSTEMTIME into it. Looks like the COleDateTime does not have a GetMilliSecond() functiion though you can subtract two COleDateTime values to get the difference.
-
October 23rd, 2009, 04:25 PM
#2
Re: Difference between two time values
you have to:
1. convert both times to milliseconds
2. subtract them
3. convert the resulting value to your old time-structure
-
October 24th, 2009, 11:57 AM
#3
Re: Difference between two time values
Or you can implement your own class that represents a time span with the desired precision.
-
October 26th, 2009, 08:12 AM
#4
Re: Difference between two time values
-
October 26th, 2009, 10:33 AM
#5
Re: Difference between two time values
Or you can use boost posix time library. You'll have to link against the data time library, though - some boost libraries only have header files, so they're easy to use, but the date time library is not one of them. If you're not using boost already in your project, that could be quite a lot of work.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|