Unit UnivDT

TUniversalDateTime - 4/29/1998 - compatible with Delphi 1.x, 2.x and 3.x ======== First the standard disclaimer, notification, etc. ============= Author: Lanny Grim E-Mail: lgrim@pop.nh.ultranet.com Copyright 1998, All rights reserved. 1) Users of UnivDT.pas must accept this disclaimer of warranty: This Unit is supplied as is. The Author disclaims all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. Author assumes no liability for damages, direct or conse- quential, which may result from the use of this Unit. 2) This Unit is donated to the public as public domain. ========= Now down to the fun part ==================================== Delphi 1 dates use a base date of Jan 1, 0001 Delphi 2/3 dates use a base date of Dec 30, 1899 ( changed for OLE Automation compatability ) For anyone having to access a database begun using Delphi 1 dates or a database which must be shared by both Delphi 1 and Delphi 2/3, the DateTime variables presents conversion issues. TUniversalDateTime alleviates most concerns when dealing with either situation. Whether it's a one time conversion fro D1 to D2/3 or an ongoing "shared" database TUniversalDateTime class handles the conversion of dates in the background. PROPERTIES: Date; Assignment to this property stores the date internally in the data source format and, if an internal flag is not set, tests the format and sets the internal flag denoting the Delphi format. If changing data sources, always call the Refresh method first. Additionally, the class is aware of the Delphi environment (D1 or D2/3) in which it is operating. Dereferencing this property returns the date in the DateTime format appropriate for the Delphi environment (D1 or D2/3) in which it is operating, not the data source. DO NOT USE this property to write to the data source. StoreDate; (read only) Returns the date in the format of the data source, assuring that the DateTime is not assigned erroneously to the data source. Use this property to write to the data source (database). StorageFormat; Returns the storage format of the current data source: 1 = Delphi 1.x 3 = Delphi 2.x - 3.x DelphiVersionsion; Returns the Delphi environment which is being used: 1 = Delphi 1.x 3 = Delphi 2.x - 3.x METHODS: function Convert( D: TDateTime ): TDateTime; Provided for convenience to allow conversion of a TDateTime variable in one step. Equivalent to assigning and then dereferencing the Date property. procedure Refresh; Resets internal flags to the same state as if the class had just been instantiated (created). The flags are then reassigned when a date is assigne to the property Date. Refresh would only be needed if you were to change data sources (data storage format). procedure TestFormat( Date: TDateTime ); Checks the format of the TDateTime variable and sets internal flags. Called internally when assignment is made to the Date property.

Classes

TUniversalDateTime -

Functions

Types

Constants

BaseDate

Variables


Functions


Types


Constants

BaseDate = 693594.0


Variables