[fpc-pascal] Explicit date from double format

Marco van de Voort marcov at stack.nl
Wed Sep 29 22:00:58 CEST 2004


> Michael Van Canneyt wrote:
> 
> >  
> >
> Or, if you need the values for some sort of calculation, you have to
> 
> - find out the reference date, i. e. DateToStr(0)
> - and the scale, (I think 1.0 = 1 day)
> - consider the month lengths, with february changing in leap years
> - for historic dates, consider calendar switches
> 
> There's a conversion function somewhere on my hard disk. If I find it, 
> I'll post it later.
> 
> Or you might scan the strings created by DateToStr. That'd be 
> quick-n-dirty, though :-)

It's a lot simpler to use simply SysUtils.DecodeDate and DeccdeTime.

Uses SysUtils;

var Year, Month, Day, hour,minute,second,msec : word;

begin
  decodedate(trunc(thetdatetime),year,month,day);
  decodetime(frac(thetdatetime),hour,minute,second,msec);
end;






More information about the fpc-pascal mailing list