Contents

Date.FormatStyle.Symbol.Minute

A type that specifies the format for the minutes in a date format style.

Declaration

struct Minute

Overview

The type Date.FormatStyle.Symbol.Minute includes static factory variables that create custom Date.FormatStyle.Symbol.Minute objects:

Factory variable

Description

Defaultdigits

The minimum number of digits that represents the numeric minute. For example, 1, 18.

Twodigits

Two-digit numeric minute, zero-padded if necessary. For example, 01, 18.

To customize the minute format in a string representation of a Date, use minute(_:). The following example shows a variety of Date.FormatStyle.Symbol.Minute format styles applied to a date.

let meetingDate = Date() // Feb 9, 2021 at 3:05 PM
meetingDate.formatted(Date.FormatStyle().minute(.defaultDigits)) // 5
meetingDate.formatted(Date.FormatStyle().minute(.twoDigits)) // 05
meetingDate.formatted(Date.FormatStyle().minute()) // 5

If no format is specified as a parameter, the defaultDigits static variable is the default format.

For more information about formatting dates, see the Date.FormatStyle.

Topics

Modifying a Minute

Comparing a Minute

Type Properties

See Also

Modifying Date Style Format Symbols