---
title: "init(style:locale:calendar:fields:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/date/componentsformatstyle/init(style:locale:calendar:fields:)"
---

# init(style:locale:calendar:fields:)

Shows the date interval with the specified style and the specified date and time fields.

## Declaration

```swift
init(style: Date.ComponentsFormatStyle.Style, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, fields: Set<Date.ComponentsFormatStyle.Field>? = nil)
```

## Parameters

- `style`: The style for the field names.
- `locale`: The locale for formatting the date interval. May affect the language in which the formatted fields are displayed and how the individual fields are connected.
- `calendar`: The calendar to interpret date values.
- `fields`: The fields to be included in the output string. Chosen automatically based on the interval being formatted if unspecified. Fields with 0 value are dropped.
