I am writing a program using PB and need to call the system time and then add or subtract from it and display it? Anyone have any suggestions or sample code to do this????
Announcement
Collapse
No announcement yet.
PB Code using System Time
Collapse
X
-
Have you considered something along the lines of:
Code:hs = hour * 3600 ' Hours to seconds ms = minute * 60 ' Minutes to seconds StartTime = hs + ms + seconds
Or there may be an API you can use that I don't know about.Last edited by Mel Bishop; 21 Feb 2008, 11:32 PM.There are no atheists in a fox hole or the morning of a math test.
If my flag offends you, I'll help you pack.
Comment
-
Why not use my Gregorian Date Library? (see my website).
Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
http://zijlema.basicguru.eu
*** Opinions expressed here are not necessarily untrue ***
Comment
-
hours, minutes, seconds. Basically I want to call the system time, save it as an integer and then add or subtract from that number in whatever format I can get it to come up as. Hope that makes sense.
i.e, there may be a much better way to do what you want to do than adding/subtracting to/from a system time saved as an integer.
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
Originally posted by Michael Mattias View Posti.e, there may be a much better way to do what you want to do than adding/subtracting to/from a system time saved as an integer.
From MSDN, structure SYSTEMTIME:
It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should
- Convert the SYSTEMTIME structure to a FILETIME structure.
- Copy the resulting FILETIME structure to a ULARGE_INTEGER structure.
- Use normal 64-bit arithmetic on the ULARGE_INTEGER value.
The system can periodically refresh the time by synchronizing with a time source. Because the system time can be adjusted either forward or backward, do not compare system time readings to determine elapsed time. Instead, use one of the methods described in Windows Time.
Comment
-
>But that's pretty much the recommended way of doing it.
Yes, that is the way you DO date-time arithmetic.... but I am suggesting you may not need to do that date-time arithmetic.
Didn't we have a thread in the last week or two which also started out with doing date-time arithmetic, but the user ended up doing either WM_TIMER or waiting on a WaitableTimer Object?
True, doing the date-time arithmetic may be required... then again, it may not.
But we just don't know in this case, do we?
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
Comment