Contents

Date.FormatStyle.Symbol.Weekday

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

Declaration

struct Weekday

Overview

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

Factory variable

Description

Abbreviated

Abbreviated weekday name. For example, Tue.

Wide

Wide weekday name. For example, Tuesday.

Narrow

Narrow weekday name. For example, T.

Short

Short weekday name. For example, Tu.

Onedigit

Local numeric one-digit day of week. The value depends on the local starting day of the week. For example, this is 2 if Sunday is the first day of the week.

Twodigits

Local numeric two-digit day of week, zero-padded if necessary. The value depends on the local starting day of the week. For example, this is 02 if Sunday is the first day of the week.

To customize the weekday, name format in a string representation of a Date, use weekday(_:). This example shows a variety of Date.FormatStyle.Symbol.Weekday format styles applied to a Thursday, using locale en_US:

let meetingDate = Date() // Feb 18, 2021 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().weekday(.abbreviated)) // Thu
meetingDate.formatted(Date.FormatStyle().weekday(.narrow)) // T
meetingDate.formatted(Date.FormatStyle().weekday(.short)) // Th
meetingDate.formatted(Date.FormatStyle().weekday(.wide)) // Thursday
meetingDate.formatted(Date.FormatStyle().weekday(.oneDigit)) // 5
meetingDate.formatted(Date.FormatStyle().weekday(.twoDigits)) // 05
meetingDate.formatted(Date.FormatStyle().weekday()) // Thu

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

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

Topics

Modifying a Weekday

Comparing a Weekday

Type Properties

See Also

Modifying Date Style Format Symbols