The full init() for Date.FormatStyle is:
init(date:time:locale:calendar:timeZone:capitalizationContext:)
The 2nd parameter type is TimeStyle, the doc is "No overview available.", but "Go to definition" in Xcode show:
/// Predefined time styles varied in lengths or the components included. The exact format depends on the locale.
public struct TimeStyle : Codable, Hashable {
/// Excludes the time part.
public static let omitted: Date.FormatStyle.TimeStyle
/// For example, `04:29 PM`, `16:29`.
public static let shortened: Date.FormatStyle.TimeStyle
/// For example, `4:29:24 PM`, `16:29:24`.
public static let standard: Date.FormatStyle.TimeStyle
/// For example, `4:29:24 PM PDT`, `16:29:24 GMT`.
public static let complete: Date.FormatStyle.TimeStyle
The comment:
The exact format depends on the locale.
"For example" in the comments seems to indicate locale determine AM/PM or 24-hour. If this is true, then it's not good because you may want to use 24-hour format in any locale.
One odd thing I see is the .omitted style doesn't actually omit:
date.formatted(Date.FormatStyle(date: .omitted, time: .omitted)) // 2/18/2022, 9:51 PM