Sign in Join
FPDoc Onlineexperiment

ISO8601ToDateDef function deprecated

In unit DateUtils

Converts an ISO 8601 date/time string to a TDateTime type.

Declaration

pascal
function ISO8601ToDateDef(const DateString: string; ReturnUTC: Boolean; 
 aDefault: TDateTime): TDateTime

Arguments

DateString

String containing the ISO 8601 date/time value converted in the function.

ReturnUTC

Indicates if the TDateTime value should be adjusted to the UTC time zone.

aDefault

Default TDateTime value used in the result.

Function result

TDateTime value for the specified ISO 8601 date/time.

Description

ISO8601ToDateDef is used to convert a date/time string in ISO 8601 format to its representation as a TDateTime value. DateString contains the ISO 8601-formatted date/time value converted in the routine. It can use one of the supported ISO 8601 date/time formats, and may contain an optional time zone offset. DateString uses the format returned from the DateToISO8601 function. Each of the following represent the date/time for Noon on July 4, 2019:

  • 20190714T08:00:00-04:00
  • 2019-07-14T08:00:00-04:00
  • 20190714T08:00:00-0400
  • 2019-07-14T08:00:00-0400
  • 20190714T08:00-04:00
  • 20190714T0800-04:00
  • 2019-07-14T0800-04:00
  • 20190714T0800-0400
  • 2019-07-14T0800-0400
  • 20190714T12:00:00
  • 2019-07-14T12:00:00
  • 20190714T12:00:00Z
  • 2019-07-14T12:00:00Z
  • 20190714T12:00
  • 2019-07-14T12:00
  • 20190714T12:00Z
  • 2019-07-14T12:00Z
  • 20190714T1200
  • 2019-07-14T1200
  • 20190714T1200Z
  • 2019-07-14T1200Z

Time values in DateString specified without a time zone offset are assumed to be in the local time zone.

ReturnUTC indicates if the value in DateString is adjusted to UTC (Coordinated Universal Time) in the return value.

aDefault contains the default TDateTime value used as the return value when DateString cannot be successfully parsed and converted.

Please note than that the overloaded variant which uses String, Boolean, and TDateTime arguments has been deprecated. Use the variant with String, TDateTime, and Boolean arguments (in that order) instead.

ISO8601ToDateDef calls the TryISO8601ToDate function in its implementation.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.