Generating a Time Standards File

Skip to first unread message

Robbert van Andel

Feb 7, 2016, 2:35:08 PM2/7/16
to SDIF Forum
I've read over a very thorough document by Troy DeLano ( that has left some questions.  What format is the time in when the conversion process begins. I'm assuming something like 7269 for 1:12.69.  Has anyone written any code to generate this file that you would be willing to share?

Mike Walsh

Feb 7, 2016, 2:51:51 PM2/7/16

Conversion from where?  What is the source of the time?  The source of the time will dictate how you would convert the time into SDIF or HY3 format.


I’ve always felt it is easier to manage time in seconds as a floating point number.  Converting from seconds to a HH:MM:SS.dd is pretty easy if your source value is always in seconds.  It also makes sorting values in a database much easier because you can do true numeric sort.


Depending on what you want to do, I may have something for you.


I wrote a WordPress plugin which supports managing a swim team.  In addition to all of the stuff needed to manage the swimmers in the context of WordPress, it can generate SDIF and Hy-tek files for entries, rosters, and some other stuff.  You can find the source here:


I also did some work on a results database that I never finished but it does have a bunch of SDIF import and export code written in PHP which you are welcome to.  You can find that here:



You received this message because you are subscribed to the Google Groups "SDIF Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Robbert van Andel

Feb 7, 2016, 2:55:09 PM2/7/16
to SDIF Forum
Thanks for getting back to me. I actually found our Wordpress code yesterday but didn't see anything there for handlin Time Standards files.  The document I referenced is for generating ST2 files. While not strictly SDIF, this is the only forum I've found that discusses anything swimming related.

Mike Walsh

Feb 7, 2016, 4:28:34 PM2/7/16

Sorry for the misdirection, I should read these closer.


While I have not personally used the ST2 format myself, in looking at Troy’s PDF, it looks like he has everything you need to construct a record.  The input time is a single precision floating point number which would almost certainly mean it is in seconds with the tenths/hundredths after the decimal point.  Storing a time for a race (or swim meet) is different than storing a time of day.


So for your original examples, 1:12.69 would be 72.69 as a floating point number then you would convert it to the ST2 format using the algorithm Troy documented.


Troy added some detail about the floating point conversion back in 2012 in a discussion here:!topic/sdif-forum/l0gWNCwjENE




From: [] On Behalf Of Robbert van Andel

Sent: Sunday, February 07, 2016 2:55 PM
To: SDIF Forum <>


Robbert van Andel

Feb 9, 2016, 3:30:03 PM2/9/16
Well, I'm getting close, but so far no luck.  My brother in law helped me write a function to do the time conversion, but I'm not sure if his code is correct (bitwise operations have always been a bit beyond me).  I also am having trouble figuring out how to take the resulting manipulated number and pack it to the file. So far I have this

private function formatTime($time1) {
//$time should be float
$time = floatval($time1);
$time = $time + 2;
//Process byte 4 (which is the exponent)

//Mask out everything else
$byte4 = $time & bindec('01111111100000000000000000000000');

//Move to first 8 bits
$byte4 >>= 23;

//Multiple by 2
$byte4 <<= 1;
//$byte4 should be correct at this stage (but double check)

//Process byte 3 (this includes add "0" to bit 8)
$byte3 = $time & bindec('00000000011111110000000000000000');
$byte3 >>= 16;

//Process byte 2
$byte2 = $time & bindec('00000000000000001111111100000000');
$byte2 >>= 8;

//Process byte 1
$byte1 = $time & bindec('00000000000000000000000011111111');

//Put them together in correct order
$hytek = 0;

$hytek = $byte4 | ($byte3 << 8) | ($byte2 << 16) | ($byte1 << 24);

return pack('f',$hytek);

You received this message because you are subscribed to a topic in the Google Groups "SDIF Forum" group.
To unsubscribe from this topic, visit
To unsubscribe from this group and all its topics, send an email to

Troy DeLano

Feb 9, 2016, 9:06:52 PM2/9/16
to SDIF Forum
Did this a while back as a test case.  I don't remember if it worked.  Have a look and see if it helps.  I will look some more when I get some time.

Robbert van Andel

Feb 9, 2016, 9:46:53 PM2/9/16

Thanks Troy. So far I have had no luck making this work. Interestingly, when I generated an ST2 file from Meet Manager, I was not able to reverse engineer the file using the formating in your documentation. I wonder if they've changed the format in the last 3 years or so.

Troy DeLano

Feb 9, 2016, 10:29:38 PM2/9/16
Can you send me an example file.  Was it .st2 or .st3.  I also have some Java to parse the file...just need to find it

Robbert van Andel

Feb 9, 2016, 11:21:52 PM2/9/16
Here's the file generated by Meet Manager.

Troy DeLano

Feb 11, 2016, 12:02:18 AM2/11/16
to SDIF Forum
There are some differences but this is not unexpected given things I'v seen in other Hy-Tek formats.  There are usually differences between the way Team Manager and Meet Manager process and create the same type of file.  For example in my description of the labels the year is replicated where as the test file you sent simply has the labels repeated (TM vs. MM?).  I do not have TM or MM in front of me but this is the results I got from parsing your test file with my parser code.  Check the file I attached.  Does the standards match what you expect (what was in the test case)?  Looking at my parser I need to check with the what I had in the PDF.  I should be able to get some time tomorrow to double check.


Robbert van Andel

Feb 11, 2016, 11:08:52 AM2/11/16
Yes, this looks right.  I am going to look at this some more over the weekend when I have some time.  Thanks for your help.

Troy DeLano

Feb 11, 2016, 6:25:40 PM2/11/16
to SDIF Forum
This is the code for converting a float to the Hy-Tek format.  It follows the diagram in the first post.  The two examples use the times from your file.  You should be able to see the converted values if you look at the file with a hex editor.  One thing my diagram did not
have was 5 bytes at the end (0x08 0x00 0x01 0x00 0x1A)which are in your test file.  I think I have seen these same values in other files so you maybe able to just append the data.  When you say you are getting close what do you mean?  If you send me the times and your generated file I can help check for errors.


for the decimal time of: 4:15.59

The 32 bit float is 0x437F970A in hex format

  0100 0011 0111 1111 1001 0111 0000 1010   in binary

  Get the exponent portion 

  Pseudo code to get exponent:  exp = (time & 0x7F80000)>>23;  // Keep bits 30:23, clear others

   100 0011 0   Exponent
   +      1 0   Add 2
   100 0100 0   Exponent+2
   x        2   Multiply by 2 (shift left 1)
  1000 1000 0   2x(Exponent+2)

  1000 1000 0111 1111 1001 0111 0000 1010   Concatenate new exponent and significand
    8    8    7    F    9    7    0    A    show in hex

             0x887F970A                     new modified 'float' value

             0x0A977F88                     Swap bytes to get into Hy-Tek format
                                            This should now match the vaules in the file


for the decimal time of: 4:20.59

The 32 bit float is 0x43824B85 in hex format

  0100 0011 1000 0010 0100 1011 1000 0101

   100 0011 1
    +     10
    x     10
   100010010 000 0010 0100 1011 1000 0101
     8   9    0    2    4    B    8    5

              Swap Bytes

Example conversion code: (java)
  The .floatToIntBits is important that it treats the float as a 3- bit int and 
  does not 'conver' the float value to an integer value!  Not sure what language 
  you are using so not sure of equivalent.

  public int floatToHyTek (float time) {
    // To convert a float to the Hy-Tek format two (2) is added to the
    // exponent (bits 30:23) and then multiplied by two (left shift of one).
    // During the shift a zero is shifted in the lsb location and the sign bit
    // is dropped.
    int hyTekFloat  = Float.floatToIntBits(time);
    int significand = hyTekFloat & 0x7fffff;
    int exponent    = ((hyTekFloat >> 23) & 0xff) + 2;
    hyTekFloat      = significand + (exponent << 24);
    // Byte swapping is done.  Not sure if this is a big/little Endian thing
    // or just manually done by Hy-Tek...
    int temp1 = (hyTekFloat >> 24) & 0x000000FF;
    int temp2 = (hyTekFloat >>  8) & 0x0000FF00;
    int temp3 = (hyTekFloat <<  8) & 0x00FF0000;
    int temp4 = (hyTekFloat << 24) & 0xFF000000;
    hyTekFloat = temp4 | temp3 | temp2 | temp1;
    return hyTekFloat;

Robbert van Andel

Feb 11, 2016, 6:48:51 PM2/11/16
Thanks Troy. I will give this a try.  I've converted your Java to PHP and will see how it goes.  The trick is the floatToIntBits part since there is no direct equivalent in PHP, but I found some discussion on it. 

$hytekFloat = unpack('i', pack('f', $float_val))[1];

The rest ports easily to PHP.  I'll try this over the weekend.

Robbert van Andel

Feb 12, 2016, 12:32:40 AM2/12/16
I am definitely close. I generated a file that includes A and B times.  I am able to import the A times but Meet Manager complains about the B times saying there are no times standards were found in the import file.  I've attached the file I generated.  Are you able to get any B times?  The first time standard is for the 8 & Under 25 free, with the following times

SCY B: 19.89
SCM B: 21.89
SCY A: 18.09
SCY B: 19.89

Attached is the file. Are you able to get the B times from the file?

Troy DeLano

Feb 12, 2016, 6:49:48 AM2/12/16
to SDIF Forum
Attached is the output I got.  Looks like you are not getting them into the right locations withing the structure. Double check the diagram.  Also in your example you have three times for B and one for A.  Are they all faster cuts or is one of them slower?  That makes a difference as to where they would be expected in the structure.

Robbert van Andel

Feb 12, 2016, 7:27:55 PM2/12/16
Ah, that was my mistake.  I was dealing with two time standards (A and B) and made the incorrect assumption that Slower and Faster meant B or A.  I've fixed it and the file is now working.  Thank you so much. I would not have been able to do this without your generous assistance.


Troy DeLano

Feb 12, 2016, 10:33:53 PM2/12/16
No problem. Great to know you have it working.  


Vasil Chopev

Feb 6, 2018, 3:10:48 AM2/6/18
to SDIF Forum
Hello Troy.First I want to thank you for detailed explanation.I am trying to parse such .std2 files. Can I see your Java code example ?
Reply all
Reply to author
0 new messages