Initializer
init(date:time:locale:calendar:timeZone:)
FormatStyle with the given configurations.init(date: Date.IntervalFormatStyle.DateStyle? = nil, time: Date.IntervalFormatStyle.TimeStyle? = nil, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, timeZone: TimeZone = .autoupdatingCurrent)
Parameters
dateThe style for formatting the date part of the given date pairs. Note that if
.omittedis specified, but the date interval spans more than one day, a locale-specific fallback will be used.timeThe style for formatting the time part of the given date pairs.
localeThe locale to use when formatting date and time values.
calendarThe calendar to use for date values.
timeZoneThe time zone with which to specify date and time values.
Discussion
Important
Always specify the date length, time length, or the date components to be included in the formatted string with the symbol modifiers. Otherwise, an empty string will be returned when you use the instance to format an object.
Note
If specifying the date fields, and the DateInterval range is larger than the specified units, a locale-specific fallback will be used.
Example: for the range 2010-03-04 07:56 - 2010-03-08 16:11 (4 days, 8 hours, 15 minutes), specifying
.hour().minute()will producefor en_US, “3/4/2010 7:56 AM - 3/8/2010 4:11 PM”
for en_GB, “4/3/2010 7:56 - 8/3/2010 16:11”