One Logo Pool Ball
Foundation · IOS API REFERENCE

Date.ParseStrategy

struct · iOS 15.0+ · SDK 27.1

struct ParseStrategy

Options for parsing string representations of dates to create a `Date` instance.

Members (14)

get · iOS 15.0+

twoDigitStartDate

TypeScript
get twoDigitStartDate(): globalThis.Date
Swift declaration
var twoDigitStartDate: Date

The earliest date that can be denoted by a two-digit year specifier.

set · iOS 15.0+

twoDigitStartDate

TypeScript
set twoDigitStartDate(value: globalThis.Date)
Swift declaration
var twoDigitStartDate: Date

The earliest date that can be denoted by a two-digit year specifier.

method · iOS 15.0+

parse

TypeScript
parse(value: string): globalThis.Date
Swift declaration
func parse(_ value: String) throws -> Date

Returns a `Date` of a given string interpreted using the current settings. - Parameter value: A string representation of a date. - Throws: Throws `NSFormattingError` if the string cannot be parsed. - Returns: A `Date` represented by `value`.

init · iOS 15.0+

init

TypeScript
static init(format: Date_FormatString, locale: (Locale) | null, timeZone: TimeZone, calendar?: Calendar, isLenient?: boolean, twoDigitStartDate?: globalThis.Date): Date_ParseStrategy
Swift declaration
init(format: Date.FormatString, locale: Locale? = nil, timeZone: TimeZone, calendar: Calendar = Calendar(identifier: .gregorian), isLenient: Bool = true, twoDigitStartDate: Date = Date(timeIntervalSince1970: 0))

Creates a new `ParseStrategy` with the given configurations. - Parameters: - format: A fixed format representing the pattern of the date string. - locale: The locale of the fixed format. - timeZone: The time zone to use for creating the date. - isLenient: Whether to use heuristics when parsing the representation. - twoDigitStartDate: The earliest date that can be denoted by a two-digit year specifier.

get · iOS 15.0+

format

TypeScript
get format(): string
Swift declaration
var format: String { get }

The string representation of the fixed format conforming to Unicode Technical Standard #35.

get · iOS 15.0+

locale

TypeScript
get locale(): (Locale) | null
Swift declaration
var locale: Locale?

The locale to use when parsing date strings with the specified format. Use system locale if unspecified.

set · iOS 15.0+

locale

TypeScript
set locale(value: (Locale) | null)
Swift declaration
var locale: Locale?

The locale to use when parsing date strings with the specified format. Use system locale if unspecified.

get · iOS 15.0+

calendar

TypeScript
get calendar(): Calendar
Swift declaration
var calendar: Calendar

The calendar to use when parsing date strings and creating the date.

set · iOS 15.0+

calendar

TypeScript
set calendar(value: Calendar)
Swift declaration
var calendar: Calendar

The calendar to use when parsing date strings and creating the date.

get · iOS 15.0+

timeZone

TypeScript
get timeZone(): TimeZone
Swift declaration
var timeZone: TimeZone

The time zone to use for creating the date.

set · iOS 15.0+

timeZone

TypeScript
set timeZone(value: TimeZone)
Swift declaration
var timeZone: TimeZone

The time zone to use for creating the date.

method · iOS 16.0+

consuming

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

Processes the input string within the specified bounds, beginning at the given index, and returns the end position of the match and the produced output. Don't call this method directly. Regular expression matching and capture calls it automatically when matching substrings. - Parameters: - input: An input string to match against. - index: The index within `input` at which to begin searching. - bounds: The bounds within `input` in which to search. - Returns: The upper bound where the match terminates and a matched instance, or `nil` if there isn't a match.

get · iOS 15.0+

isLenient

TypeScript
get isLenient(): boolean
Swift declaration
var isLenient: Bool

Indicates whether to use heuristics when parsing the representation.

set · iOS 15.0+

isLenient

TypeScript
set isLenient(value: boolean)
Swift declaration
var isLenient: Bool

Indicates whether to use heuristics when parsing the representation.

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →