Announcement

Collapse
No announcement yet.

Easy time related question

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

  • Easy time related question

    OK, still working on the Event Log.

    I have now acquired:

    lpBuffer.TimeGenerated

    This is in seconds since 1970...
    So I'm thinking along these lines but it is not working...

    I'd like to return it in a date format readable
    Code:
    Function ReturnDate(inTime As Dword) As String
    Local st            As SYSTEMTIME
    Local tDay              As Asciiz * 64
    Local tTime             As Asciiz * 64
    
    VariantTimeToSystemTime inTime,st
    ' -- Create a date string using the local settings
    GetDateFormat %LOCALE_USER_DEFAULT, %NULL, st, "MMM dd',' yyyy", tDay, 64
    ' -- Create a time string using the local settings
    GetTimeFormat %LOCALE_USER_DEFAULT, %TIME_NOSECONDS, st, "hh:mm tt", tTime, 64
    Function = tDay + " " + tTime
    End Function


    ------------------
    Scott
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Scott --
    You mix something

    A variant time is stored as an 8-byte real value (double), representing a date between January 1, 1753 and December 31, 2078, inclusive. The value 2.0 represents January 1, 1900; 3.0 represents January 2, 1900, and so on. Adding 1 to the value increments the date by a day. The fractional part of the value represents the time of day. Therefore, 2.5 represents noon on January 1, 1900; 3.25 represents 6:00 A.M. on January 2, 1900, and so on. Negative numbers represent the dates prior to December 30, 1899.
    ------------------
    E-MAIL: [email protected]

    Comment


    • #3



      OK Thanks!
      Let me rephrase the question then?

      How do I determine the date from "Seconds since 1970"

      Scott

      ------------------
      Scott
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Scott,

        I think you have to use Julian dates (one of the many) .. convert
        01.01.1970 to a Julian date .. integer divide the number of seconds
        by 24*60*60 to get the number days ... and add those to together and
        convert back. That should get you the date. If you MOD instead of divide
        you should be able to arrive at the time of day.

        Mike


        ------------------

        Comment


        • #5
          Scott
          Check the source form from some Unix date and time routines that I just posted,
          they maybe of some help.

          Regards;
          Errol

          ------------------

          Comment


          • #6
            originally posted by scott turchin:
            let me rephrase the question then?

            how do i determine the date from "seconds since 1970"

            scott

            i posted a couple of routines here a few days ago for dat/time arithmetic. see http://www.powerbasic.com/support/pb...ead.php?t=3874

            this includes a function dtgseconds which determines the number of seconds from "0/0/0000 00:00:00"

            just adding a "- 62167132800" should do the trick ( since dtgceconds returns that number for "1-1-1970 00:00:00"





            ------------------
            check out my free software at http://www.lexacorp.com.pg(all written in pb/dll)

            Comment

            Working...
            X