The Unofficial Newsletter of Delphi Users - by Robert Vivrette




A Universal Date/Time Class

by Lanny Grim - lgrim@pop.nh.ultranet.com

In my programming efforst, I often found myself using data files with DateTime stored in Delphi 1 format and I was working with Delphi 3.  Then I found I wanted to use Dates in Delphi 1 that were created by Delphi 3.

UNIVDT.PAS implements a class TUniversalDateTime to resolve the problems associated with converting from D1 -> D2/3 or from D2/3 -> D1 DateTime
formats.  It takes the guesswork and tedium out of it (for me at least).  I am provide it below in the homes that others might find it useful.

UNIVDT.PAS is the unit is question and has an explanation of properties and functions at the top of the file. Also included in the zip file is a demo project created in D1.  It will load and compile in both D1 and D3.  I did not test the demo project in D2, but it should work there as well.  The demo shows how the TUniversalDateTime class is instantiated and used.

Click here to download the code and demo project.