Announcement

Collapse
No announcement yet.

PB Code using System Time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    >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?

    MCM

    Leave a comment:


  • Knuth Konrad
    replied
    Originally posted by Michael Mattias View Post
    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.
    But that's pretty much the recommended way of doing it.

    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.

    Leave a comment:


  • Elias Montoya
    replied
    Originally posted by Egbert Zijlema View Post
    Why not use my Gregorian Date Library? (see my website).
    I second that, they are great.

    Leave a comment:


  • Michael Mattias
    replied
    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.
    Well, it makes sense in that I understand.. but... that's not what you want to do, that's how you want to do <whatever it is>.

    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.

    MCM

    Leave a comment:


  • Wyatt Chiltoskie
    replied
    Thanks for the help!!! Will see what I can do with the info.

    Leave a comment:


  • Egbert Zijlema
    replied
    Why not use my Gregorian Date Library? (see my website).

    Leave a comment:


  • Kev Peel
    replied
    There are a LOT of examples of using the API date functions on the forum. Search for "FILETIME", "Date Routines" or "DateDiff"/"DateAdd".

    Here is one example:

    PowerBASIC and related source code. Please do not post questions or discussions, just source code.

    Leave a comment:


  • Mel Bishop
    replied
    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
    Do your math thing then convert back to HH:MM:SS.

    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.

    Leave a comment:


  • Wyatt Chiltoskie
    replied
    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.

    Leave a comment:


  • Mel Bishop
    replied
    Add or subtract what?

    Leave a comment:


  • Wyatt Chiltoskie
    started a topic PB Code using System Time

    PB Code using System Time

    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????
Working...
X