One Logo Pool Ball
Foundation · IOS API REFERENCE

DateComponents.HTTPFormatStyle

struct · iOS 26.0+ · SDK 27.1

struct HTTPFormatStyle

Converts `DateComponents` into RFC 9110-compatible "HTTP date" `String`, and parses in the reverse direction. This parser does not do validation on the individual values of the components. An optional date can be created from the result using `Calendar(identifier: .gregorian).date(from: ...)`. When formatting, missing or invalid fields are filled with default values: `Sun`, `01`, `Jan`, `2000`, `00:00:00`, `GMT`. Note that missing fields may result in an invalid date or time. Other values in the `DateComponents` are ignored.

Members (5)

get · iOS 26.0+

parseStrategy

TypeScript
get parseStrategy(): DateComponents_HTTPFormatStyle
Swift declaration
var parseStrategy: DateComponents.HTTPFormatStyle { get }

A `ParseStrategy` that can be used to parse this `FormatStyle`'s output

method · iOS 26.0+

parse

TypeScript
parse(value: string): DateComponents
Swift declaration
func parse(_ value: String) throws -> DateComponents

Parses a value, using this strategy. This method throws an error if the parse strategy can't parse `value`. - Parameter value: A value whose type matches the strategy's ``ParseStrategy/ParseInput`` type. - Returns: A parsed value of the type declared by ``ParseStrategy/ParseOutput``.

method · iOS 26.0+

format

TypeScript
format(components: DateComponents): string
Swift declaration
func format(_ components: DateComponents) -> String

Formats a value, using this style. Use this method when you want to create a single style instance, and then use it to format multiple values. - Parameter value: The value to format. - Returns: A representation of `value`, in the ``FormatOutput`` type, formatted according to the style's configuration.

method · iOS 26.0+

consuming

TypeScript
consuming(input: string, index: SDKHandle, bounds: SDKHandle): ({ "upperBound": SDKHandle; "output": DateComponents }) | null
Swift declaration
func consuming(_ input: String, startingAt index: String.Index, in bounds: Range<String.Index>) throws -> (upperBound: String.Index, output: DateComponents)?

Process the input string within the specified bounds, beginning at the given index, and return the end position (upper bound) of the match and the produced output. - Parameters: - input: The string in which the match is performed. - index: An index of `input` at which to begin matching. - bounds: The bounds in `input` in which the match is performed. - Returns: The upper bound where the match terminates and a matched instance, or `nil` if there isn't a match.

init · iOS 26.0+

init

TypeScript
static init(): DateComponents_HTTPFormatStyle
Swift declaration
init()

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →