Sign in Join
FPDoc Onlineexperiment

TryISOStrToTime function

In unit DateUtils

Converts an ISO 8601-formatted time value to a TDateTime type.

Declaration

pascal
function TryISOStrToTime(const aString: string; out outTime: TDateTime)
: Boolean

Arguments

aString

ISO 8601 time value converted in the function.

outTime

TDateTime type containing the time value from the function.

Function result

True if the time value is successfully converted to a TDateTime type.

Description

TryISOStrToTime is a Boolean function which attempts to convert the specified ISO 8601 time value to a TDateTime type. aString contains the ISO 8601 time value examined in the function, and can use one of the following notations:

  • hh (hours)
  • hhnn (hours and minutes)
  • hhnnss (hours, minutes, seconds)
  • hhnnss.zzzz (arbitrary number of decimal places for fractions of a second)
  • hhnnss.zzzzZ (arbitrary precision and Zulu time zone designation)
  • hhnnss.zzzz±hh (timezone offset in hours)
  • hhnnss.zzzz±hhnn (timezone offset in hours and minutes)
  • hhnnss.zzzz±hh:nn (timezone offset in hours and minutes)
  • hh:nn (hours and minutes)
  • hh:nn:ss (hours, minutes, seconds)
  • hh:nn:ss.zzz (arbitrary number of decimal places for fractions of a second)
  • hh:nn:ss.zzzZ (arbitrary precision and Zulu time zone designation)
  • hh:nn:ss.zzz±hh (timezone offset in hours)
  • hh:nn:ss.zzz±hhnn (timezone offset in hours and minutes)
  • hh:nn:ss.zzz±hh:nn (timezone offset in hours and minutes)

aString may contain an optional time zone designation at the end of the string value, like 'Z' for Zulu time zone or a time zone offset expressed using either positive or negative hours and minutes. For example:

  • 120000Z
  • 080000-04
  • 080000-0400
  • 080000-04:00
  • 12:00:00Z
  • 08:00:00-04
  • 08:00:00-0400
  • 08:00:00-04:00

The return value is True if the time value in aString is successfully converted in the function.

outTime is a TDateTime type used to store the time value converted in the function. When the return value is False, outTime contains 0 for an empty time value.

Use TryISOStrToDate to convert an ISO 8601 date value to a TDateTime type.

Use TryISOStrToDateTime to convert a string which contains both date and time values to a TDateTime type.

See also

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