TIdTime
Implements a Time client.
Unit
Description
TIdTime is a client implementation of the Time Protocol as described in the Internet Standards document:
- RFC 868 - Time Protocol (http://www.rfc-editor.org/rfc/rfc868.txt)
Time is a simple protocol for synchronizing time on a local network. For a time protocol with higher accuracy over several networks, use TIdSNTP. To retrieve the current date and time in human-readable form, use TIdDayTime.
Please note that the Time Protocol in its current form cannot handle most dates after the year 2035. This limitation is stated in RFC 868.
Initial Date used for time server calculations.
property BaseDate: TDateTime;
Description
BaseDate is a TDateTime property that indicates the initial date used for Time server calculations. When the BaseDate for the client and server are identical, and exceeds the value of
DateTime,
DateTime can contain values beyond the year 2035.
Do not change BaseDate unless the Time server uses the same value for it's BaseDate.
Current date and time from the server.
property DateTime: TDateTime;
Description
DateTime is a read-only TDateTime property that reflects the estimated current date and time according to a Time server. DateTime is expressed in the timezone for the local computer.
DateTime will contain the value 0.0 (for 12/30/1899 12:00 am) when no date and time values have been assigned.
The Host and Port properties must contain a valid Time server address and port assignment prior to accessing the value of DateTime.
Number of seconds since the base Time server date.
property DateTimeCard: Cardinal;
Description
DateTimeCard is a read-only Cardinal property that represents the number of seconds since 1/1/1900 12:00am.
The Host and Port properties must contain a valid Time server address and port assignment prior to accessing the value of DateTimeCard. DateTimeCard will open a connection to the time server, retrieve the property value, and close the server connection.
Port number for the Time protocol.
Description
Port is an Integer property that represents the port number used by the Time protocol. Port is redefined in
TIdTime to establish the default port number for the protocol (
IdPORT_TIME).
property RoundTripDelay: Cardinal;
Description
RoundTripDelay is a read-only Cardinal property that indicates the estimated number of milliseconds required to receive data from the server. RoundTripDelay is used to adjust the calculated
DateTime property.
Indy read delay in milliseconds.
property Timeout: Integer;
Description
Timeout is an Integer property that represents the number of milliseconds Indy read operations must wait for a readable connection. For
TIdTime, the default value of TimeOut is 2500 (2.5 seconds).
Constructor for the object instance.
constructor Create(AOwner: TComponent); override;
Description
Create is the constructor for the object instance. Create sets the default port to the standard port number used for the Time protocol (
IdPORT_TIME), and sets
BaseDate to Jan 1, 1900 as specified by the Time protocol.
Updates local time to match the Time server.
function SyncTime: Boolean;
Return Value
Boolean - True when local time has been updated.
Description
SyncTime is a Boolean function used to synchronize the local system clock with the Time server. When the value from the server is not empty, the local system clock will be updated.