swift-formatstyle
Installation
SKILL.md
Swift FormatStyle (iOS / macOS)
Locale-aware, value-to-string formatting (and string-to-value parsing) built on
Foundation's FormatStyle protocol. This is the modern, type-safe replacement
for NumberFormatter, DateFormatter, DateComponentsFormatter, and friends —
prefer it for all new code.
- Baseline availability:
FormatStyle, number/date/list/measurement/person-name styles are iOS 15+.Durationstyles (.units/.time) and theFormatStyle-basedByteCountFormatStyle(.byteCount) are iOS 16+. - KMP boundary: keep the numeric value (a
Decimal,Date, orMoney) in shared code; format only at the iOS presentation layer. Never hand aDoubleacross the boundary for money — seekmp-money. - Two entry points, equivalent:
value.formatted(style)— call on the value.style.format(value)— call on the style (useful when the style is stored/reused).