LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  How to convert FILETIME 16 character hex string into regular date and time

    Employee
    Posted 03-10-2015 08:35

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: djnrempel

    I have a set of a couple million audio files and I need to figure out when each one started. The start time is embedded in the file name in two different ways, as in this example:

    20140401-0916--01cf4d8b18336cd0


    The first one is easy to read, it means the file started at 9:16 a.m. on 2014/04/01. Unfortunately this only tells me to the closest minute and I need the closest second.

    The second format is a FILETIME format, which is a convention that uses a 16 character hexadecimal value to indicate the number of 100 nanosecond increments that have elapsed since Jan. 1, 1601.


    The logic of converting a hexadecimal to a decimal is not that hard, the problem I run into is that the numbers are larger than it seems either a LONG or INT can hold, so I can't even be sure that my conversion script is giving me any kind of accurate result because the calculations on the last few digits may give accurate results.

    If it is accurate but just rounded, that's probably fine as long as I still have a resolution of one second.

    Typing this out has given me some ideas of things to test and try, so I will report back, but if anyone has any quick and easy answers/advice, I'm all ears.


  • 2.  RE: How to convert FILETIME 16 character hex string into regular date and time

    Employee
    Posted 03-10-2015 09:33

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    Hi, Daniel. A good question! So to break down the problem into parts, I first needed to extract the FILETIME characters and convert it to long integer type. I used Stony's example for the conversion.

    Then I basically converted the 100-ns increments to seconds, and used dateTimeAdjust to get the result.

    You are correct in that a 16-character hex number has a greater maximum value than of a long int, but this should work for date ranges in our lifetime. A 16-char hex goes from 0 to 2^64 -1. A long only goes to 2^63-1 (goes to 2^63 on the negative side). This value (in FILETIME) translates to September 13, 30828 9:48:05pm.
    Attachments:
    filetimeConversion.brg


  • 3.  RE: How to convert FILETIME 16 character hex string into regular date and time

    Employee
    Posted 03-10-2015 09:57

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: djnrempel

    Thanks Ryan!

    What is the best way to import this into an existing graph? I tried dragging and dropping the file but it just opened it and closed my other one. Is there an import function?

    Also it tells me I'm missing "r.brg", do I need to download something?


  • 4.  RE: How to convert FILETIME 16 character hex string into regular date and time

    Employee
    Posted 03-10-2015 10:06

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    Oh, right. I have my graphs to include the R-library by default. You can ignore that warning, as it's not needed for this graph.

    I've attached a new version. You should be able to copy and paste the composite (Convert FILETIME) into your graph. Another trick is to change the file extension to *.brn, i.e. filetimeConversion.brn. Then you can drag that BRN file directly into an existing graph.
    Attachments:
    filetimeConversion_v1.brg


  • 5.  RE: How to convert FILETIME 16 character hex string into regular date and time

    Employee
    Posted 03-10-2015 10:26

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: djnrempel

    Thanks for that tip re *.brn.

    I incorporated the code and it works beautifully! The audio files max out at five minutes in length, so I can see from the start times that these are lining up correctly. This makes my dataset a lot more accurate, thanks!

    I also just realized I can ignore the first character as it should be a 0 in all cases anyway, so that shaves off 1/16th of those calculations anyway.