Internet Direct (Indy)
Home
PreviousUpNext
TIdThreadSafeDateTime Class

Implements a thread-safe DateTime data type.

Pascal
TIdThreadSafeDateTime = class(TIdThreadSafe);

TIdThreadSafeDateTime is a TIdThreadSafe descendant that implements a thread-safe data type for storing a TIdDateTime value. 

TIdThreadSafeDateTime uses TIdCriticalSection for resource protection in multi-threaded applications. 

TIdThreadSafeDateTime implements the Value property for reading or writing the native data type for the class instance using resource protection. 

TIdThreadSafeDateTime also implements methods that protect write access to the Value for the data type when performing date arithemtic operations in Add and Subtract

 

On the Win32 and Linux platorms, TIdDateTime is defined as a Double (64-bit floating-point number). Date and time information in TIdDateTime is stored as the number of days since midnight on 30-Dec-1899. 

 

On the .Net platform, TIdDateTime is a record that handles implicit conversions to and from a Double value. Internally, the Date/Time value is stored using the System.DateTime type from the Framework Class Library. 

System.DateTime was designed to hold dates and times, while Double (the original TDateTime) was designed to hold floating-point numbers. Delphi coders relied on this small, but critical, implementation detail. Since TDateTime was a double, it was easy to perform arithmetic operations on it - for example, subtracting one TDateTime from another to get the difference between them in days. Occasionally, the difference was negative (the first date was later then the second date), and if your code allows that, it will no longer work. Instead, you'll get the absolute value of the difference. Use TDateTime's ToOADate method to get a value compatible with previous versions of Delphi.

Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.