Virtual Pascal

Classic Object Pascal for free

Contents/structure/layout of tDateTime (as in VPSYSLow)

G'day Folks,

Would anyone know the actual bit-pattern layout of the tDateTime (double), ie: 64-bit variable, as used in the various DateTime routines, please? ie: which bits denote the: year month day hour min secs etc ..or if they are counts ... counts of what, please?

I've searched around but couldn't find it in the various help & source files - although I did find the description of the timestamp fields...
If I've missed it there, feel free to give me a virtual 'kick-up-the-bum'! :-))) ..and tell me where it is... Thanks.

I would like to code a small amount of assembler to convert to/from a tDateTime (double) to use with MJDate as found in DateProx Unit (by
It can be done by converting via text fields (eg: year/month/day etc) - but that is (a) blazingly s-l-o-w, (b) anathema to me ..... and almost certainly unnecessary ... for the sake of a little assembler code...

Many Thanks

Views: 257

Reply to This

Replies to This Discussion

I think the simplest way to decode a datetime variable is to use one of the conversion functions that are in SysUtils.

The easiest probably are DecodeDate and DecodeTime:
procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word);

- but there are many more, and they are relatively efficiently implemented. There are no fixed bits that represent the different parts of the date, although I think the fractional portion is the time.

Does this help? What does the DateProx unit do that is cool?
Crikey - I must be thick! I completely missed those ....
Thanks Allan !

I've just emailed Dr Stockton to ask if either he has a VP version of DATEPROX - or whether he will permit me to post the version I've converted .. onto the VP site (ie: here). Though I am no expert on the matter, it seems to me that Dateprox will convert between almost any Calendar and form of date you might want .... except (currently) ... tDateTime ...hopefully soon to be rectified :-))

No problem at all :)

I did a quick search and found his code here:

Judging from the comments and the code, tDateTime is well known to the author, although DELPHI needs to be defined to enable the functions that use it. Between what is in SysUtils and what is in this library, I think you can convert between whatever you want :)

FWIW, Delphi 6 and later added a new DateUtils unit to the RTL. As far as I recall, it also includes a large number of date and time related conversion functions.

Good luck!
FPC has a DateUtils unit. There might be some minor functionality of newer Delphi's in there (default params), but that should be trivial to remedy.
The double type occupies 8 bytes of storage space, and its memory structure is the same as the
IEEE-754 double type.
Its structure is similar of other real types
1 bit sign
11 bit exponent
52 bit mantissa

The fractional part is the time of the day. Eg. 0.01 represents 864 sec after midnight
The integer part is the days after a special date, I think it is 1900.jan.1
Try it with:
(Listing: ./sysutex/ex18.pp)
program example18 ;
Uses sysutils;
writeln ( ’Now : ’ , Now ) ;
end .
then count the integer part as days backwards from now ...

For assembler ?? Do You like to use coprocessor in assembler? I don't.

Ludwig from Hungary
One or one-half day earlier actually. Has to do with some mistake in early Excel's that took 1900 for a leapyear.

One indeed shouldn't code such things in assembler anymore. Since that code will break on 64-bit, (which only has SSE2 FPU, and not x87) and nearly every machine sold today is 64-bit already.


© 2022   Created by Allan Mertner.   Powered by

Report an Issue  |  Terms of Service