File date 
Author Message
 File date

I know using that I can get the date and time of a file using GetFTime
or the appropriate Dos Call.
GetFtime returns a longint with the information of the date and time. I
can use the Unpack procedure to translate this information.
My question is, what is the format of that longint returned? How can I,
without using unpack, know the date and time... For example, how can I
know if GetFtime returns me 50198?

(I know that if I use the Dos Call $2F, I can get the DTA address and
from there access the time from the date. But again, what do those bytes
mean? how can I translate them?)

If anyone one knows this, I would appreciate some help... It's curiosity
mostly, since I can just use the unpack procedure.

Thank you.



Fri, 03 Dec 1999 03:00:00 GMT  
 File date

Quote:

>I know using that I can get the date and time of a file using GetFTime
>or the appropriate Dos Call.
>GetFtime returns a longint with the information of the date and time. I
>can use the Unpack procedure to translate this information.
>My question is, what is the format of that longint returned? How can I,
>without using unpack, know the date and time... For example, how can I
>know if GetFtime returns me 50198?

>(I know that if I use the Dos Call $2F, I can get the DTA address and
>from there access the time from the date. But again, what do those bytes
>mean? how can I translate them?)

>If anyone one knows this, I would appreciate some help... It's curiosity
>mostly, since I can just use the unpack procedure.

You could use a TypeCast, a variant record, or an absolute
variable to allow treating the DTA as a tSearchRec, then use
UnpackTime.  This technique would give you the info you want and
you still wouldn't have to be concerned with the packed format.

From the MS/DOS Encyclopedia:
INT 21h - Function 57h - Get/Set File Date/Time returns date in DX
and time in CX.  

Time: CX = Bits  0-4   Number of Seconds div 2
                 5-10  Minutes 0..59
                11-15  Hours 0..23

Date: DX = Bits  0-4   Day of Month 1..31
                 5-8   Month 1..12 (January=1, ...)
                 9-15  Year minus 1980

The above is also listed under DOS FindFirst/FindNext, Functions
4Eh/4Fh, which lists Time at offset 16h and Date at offset 18h
within the DTA.

You can experiment to be certain, but my guess is the longint used
by TP is formed from DX:CX (DX high word) which agrees with
treating offset 16h of the searchrec as a longint.

I've used the fact that DOS appears not to check values when
setting or retrieving the date/time of a file to stamp a file with
a value that would indicate that it hasn't been altered outside of
a particular program.  For example, setting seconds to a value of
30 or 31, (1Eh..$1Fh) would be out-of-range at 60 or 62 seconds,
would not appear on normal directory listings, but would be reset
if the file was altered.  Ex. Time := (Time and $FFFFFFE0) or $1F

    ...red



Sat, 04 Dec 1999 03:00:00 GMT  
 File date




Quote:
>You can experiment to be certain, but my guess is the longint used
>by TP is formed from DX:CX (DX high word) which agrees with
>treating offset 16h of the searchrec as a longint.

It is; AFAIR, I was sure of it before I decided to use it thus - and I
use it so often that I'd have noticed by now if I was wrong.

The longint increases monotonically, with a step every 2 seconds (very
nearly; it must be calculated from the 18.2Hz clock); but the steps are
only of size one at seconds=2*(1..29).  At each minute, there must be an
extra 2 steps; at each hour a further extra 4*30, at midnight a further
extra 8*60*30, yet more at the end of the month, and even more at the
end of the year.  

It can therefore be used for date+time sorting, but to accommodate dates
after 2043, it will need adjustment (xor $80000000 ?).
--

  Web URL: http://www.merlyn.demon.co.uk/ -- includes FAQqish topics and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Before a reply, quote with ">" / "> ", known to good news readers (SoRFC1036)



Sat, 04 Dec 1999 03:00:00 GMT  
 File date

Quote:



>>You can experiment to be certain, but my guess is the longint used
>>by TP is formed from DX:CX (DX high word) which agrees with
>>treating offset 16h of the searchrec as a longint.

I thought they used DX:AX? (which I believe would correspond nicely
with several x86 opcodes, like mul, that return 32 bit results using that
register combo)

--
=\

=/



Mon, 06 Dec 1999 03:00:00 GMT  
 File date

Quote:




>>>You can experiment to be certain, but my guess is the longint used
>>>by TP is formed from DX:CX (DX high word) which agrees with
>>>treating offset 16h of the searchrec as a longint.

>I thought they used DX:AX? (which I believe would correspond nicely
>with several x86 opcodes, like mul, that return 32 bit results using that
>register combo)

Yes, a TP function returns a longint in DX:AX.  DOS, however,
often deviates from what you or I would consider to be "normal"
registers for passing parameters and return values.  In the case
of DOS INT 21h - Function 57h - Get/Set File Date/Time, the date
is returned in DX and time in CX.

The original post requested information about the structure of
the longint returned by TP's GetFTime procedure.  I am not aware
of this information being available except by reading the ASM
source to the appropriate RTL routines.  Rather than do this, I
chose to "assume" that the longint "Time" returned by the TP
procedure GetFTime(VAR F; VAR Time: Longint) is the same as
DX:CX returned by Function 57h and reported on the format of
those words as presented in the MS/DOS Encyclopedia.

I also believe that the longint in TP's tSearchRec.Time (offset
22 in tSearchRec) is the same as the Time (word at offset 16h)
and Date (word at offset 18h) within the DTA returned by DOS
FindFirst/FindNext. I based this assumption on the fact that the
MS/DOS Encyclopedia lists the date and time for both functions
as having the same format. I also assume by the arrangement of
the words in the DTA that the DOS "DATE:TIME" is the longint
used by TP's Pack/UnpackTime procedures.

Regardless how strong I might believe these assumptions to be
true, I haven't verified them.  If you want to be certain that
they are true, you'll have to check for yourself.

    ...red

--
Support the anti-Spam amendment
  Join at http://www.cauce.org/



Tue, 07 Dec 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Windows 95 file dates

2. TP 5.5 file date under NT wrong

3. Get/Set TBufStream file date & time?

4. Getting file *creation* date, not modified date

5. DBase header info (file size, last change date)

6. BDE Engine error: Index file out of date...

7. Change File's date creation?

8. Determining date/time file was last modified/accessed

9. File time and date won't change

10. Corrupt lock files, Index out of date etc.

11. FILE CREATION DATE & TIME

12. File CREATION date TP7 (windows NT?

 

 
Powered by phpBB® Forum Software