Indy 9
DateTimeToGmtOffSetStr
See Also, Unit: IdGlobal
Retrieves the GMT time offset for a date/time value.
function DateTimeToGmtOffSetStr(ADateTime: TDateTime; SubGMT: Boolean): string;
Unit
IdGlobal
Parameters
ADateTime: TDateTime
Value to be converted to a GMT offset string.
SubGMT: Boolean
Add the prefix "GMT" to the return value.
Return Value
String - The offset from GMT time as a string.
Description
DateTimeToGmtOffSetStr is a String function used to return the time difference for the ADateTime parameter as an Internet Time difference string. The time difference contains the number of hours and minutes needed to adjust a time value the local timezone to GMT (Greenwich Mean Time). The return value for DateTimeToGmtOffSetStr is expressed in one of the following forms:

  • GMT - Same as GMT, offset is 0 hours and 0 minutes.

  • -0500 - Local time is 5 hours and 0 minutes earlier than GMT.

  • +0130 - Local time is 1 hour and 20 minutes later than GMT.

ADateTime is the native Date/Time value containing the number of hours and minutes to use for the local timezone. ADateTime is not a complete Date/Time value.

SubGMT indicates that the return value should substitute the prefix "GMT" for a time difference string where the offet is 0 hours and 0 minutes. When SubGMT is True, the prefix is used as the time difference string, otherwise the prefix is omitted.

DateTimeToGmtOffSetStr calls DecodeTime to extract the hour and minute components of ADateTime. When ADateTime contains a negative offset, the return value is formatted using the convention:

    -HHMM

When ADateTime contains a positive offset, the return value is formatted using the convention:

    +HHMM

Where HH represents the 2-digit number of hours in the offset, and MM represents the 2-digit number of minutes in the offset.

To convert an Internet GMT difference string to a TDateTime value that can be used in Date arithmetic operations, use the GmtOffsetStrToDateTime function.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.