Date.FormatStyle.Symbol.SecondFraction
A type that specifies the format for the second fraction in a date format style.
Declaration
struct SecondFractionOverview
The type Date.FormatStyle.Symbol.SecondFraction includes static factory methods that create custom Date.FormatStyle.Symbol.SecondFraction objects:
Factory variable | Description |
|---|---|
Returns the numerical representation of the fractional component of the second. For example, | |
Returns the number of milliseconds elapsed in the day. For example, |
To customize the second format in a string representation of a Date, use secondFraction(_:). The following example shows a variety of Date.FormatStyle.Symbol.SecondFraction format styles applied to a date.
let meetingDate = Date() // Feb 9, 2021 at 3:05:41 PM
meetingDate.formatted(Date.FormatStyle().secondFraction(.fractional(3))) // 827
meetingDate.formatted(Date.FormatStyle().secondFraction(.fractional(1))) // 8
meetingDate.formatted(Date.FormatStyle().secondFraction(.milliseconds(4))) // 11122827For more information about formatting dates, see the Date.FormatStyle.
Topics
Modifying a Second Fraction
Comparing Second Fractions
Type Properties
See Also
Modifying Date Style Format Symbols
Date.FormatStyle.Symbol.CyclicYearDate.FormatStyle.Symbol.DayDate.FormatStyle.Symbol.DayOfYearDate.FormatStyle.Symbol.DayPeriodDate.FormatStyle.Symbol.EraDate.FormatStyle.Symbol.HourDate.FormatStyle.Symbol.MinuteDate.FormatStyle.Symbol.MonthDate.FormatStyle.Symbol.QuarterDate.FormatStyle.Symbol.SecondDate.FormatStyle.Symbol.StandaloneMonthDate.FormatStyle.Symbol.StandaloneQuarterDate.FormatStyle.Symbol.StandaloneWeekdayDate.FormatStyle.Symbol.TimeZoneDate.FormatStyle.Symbol.VerbatimHour