C/convert file date/time from conventional format to DOS format
Expert: Narendra - 7/23/2004
Question
I've accessed information about files on my machine using a linked list created using C language code. Information is file names, size, dates and time. The file dates and times are in 16-bit DOS format. I wrote a C code to convert the date and time to conventional format(using bit mask and right shift). eg. DOS date formats 12367 and 11341, were converted to conventional date formats 15 feb 2004 and 13 february 2002 respectively. DOS time formats 5604 and 24909 were converted to conventional time formats 2:41:4 and 12:8:13 respectively. However I cannot figure out how to do the reverse, ie. convert from conventional date and time to DOS format. I figured how to convert the first date from conventional to DOS but the algorithm did not work with the other values.
Thanks for your help in doing this conversion.
AnswerBefore going ahead with writing the program, you must understand the problem fully.
So, create few test cases and solve them manually.
By this you will understand what is the input, what is the output and how to get the desired output.
Since you know the steps clearly, you can anticipate the results in intermediate steps and see if it is doing everything correctly.
So, in this case (Convert from conventional date/time to DOS format) also, you will have to do the same.
Take some examples of conventional date/time. forget the program that you written and convert these date/time to DOS format manually. After that go into the progam and solve.
Since, I don't have your program and also I don't know the exact formats, I will not be able to tell you where you went wrong.
Hope this helps.
If you can give me the code, sample input and output and also the formula which does the conversion, I will try to debug and give solution.
-ssnkumar