Announcement

Collapse
No announcement yet.

Windows FILETIME conversion

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

  • Matthew Berg
    replied
    mark,

    i have just posted to the source code forum some code which should demonstrate how this can be done with pb/dos. see the thread convert a windows filetime value to a date string.

    hth

    Leave a comment:


  • Tom Hanlin
    replied
    Good point-- although a good average value for the year interval will mostly overcome any rounding problems. We're talking about mighty small intervals.

    A search on "Julian" in the Forums here should turn up any number of examples.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Matthew Berg
    replied
    To get the year, divide the file time by the number of 100-nanosecond intervals in a year, and add 1601. Take the remainder from this division, and divide it by the number of 100-nanosecond intervals in a month to get the month... etc.
    Using this method to derive date components from an integer value is prone to error for the simple fact that both years and months have variable lengths. Making assumptions like this will introduce rounding errors, which will get worse the further away from 1601 you get.

    Leave a comment:


  • Tom Hanlin
    replied
    MSDN says, "The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC)." Fortunately, PB/DOS supports QUADs, so you can do this sort of calculation without too much trouble. To get the year, divide the file time by the number of 100-nanosecond intervals in a year, and add 1601. Take the remainder from this division, and divide it by the number of 100-nanosecond intervals in a month to get the month... etc.

    If you don't want the results in UTC, it will probably be easiest if you calculate the bias for local time as a QUAD value first, and apply it before you start all the other calculations. Otherwise, you're facing a cascade effect where adjusting the time may put you on a different day, which may mean adjusting the month, etc.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Matthew Berg
    replied
    Don't suppose you are able to call a (Windows) console application which uses the FileTimeToSystemTime() API function to convert the integer into a date/time value?

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Windows FILETIME conversion

    Windows FILETIME conversion

    I am writing a program to print out the OFFITEMS log from windows
    Included in the file are filenames with a 8Byte FILETIME next to the
    filename.

    I need to convert the 8 byte filetime (64bit) into a regular
    time and date we can all read.

    I am under the gun and would like to know if anyone has code to convert
    the 8bytes to regular date and time. I have the file layout figured out
    just not how the 8 bytes (64bits) work.

    ------------------
Working...
X