# Swift Formatstyle

Formats and parses locale-aware numbers, decimals, currencies, percentages, dates...

- Repository: https://github.com/dpearson2699/swift-ios-skills (1266 stars)
- Category: Design
- License: see repository
- Last updated: 2026-07-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add dpearson2699/swift-ios-skills --skill swift-formatstyle -g -a claude-code -y`
Codex: `npx skills add dpearson2699/swift-ios-skills --skill swift-formatstyle -g -a codex -y`
Cursor: `npx skills add dpearson2699/swift-ios-skills --skill swift-formatstyle -g -a cursor -y`
Gemini CLI: `npx skills add dpearson2699/swift-ios-skills --skill swift-formatstyle -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add dpearson2699/swift-ios-skills`

## Description

Formats and parses locale-aware numbers, decimals, currencies, percentages, dates, durations, measurements, names, lists, byte counts, and URLs with Foundation FormatStyle and ParseableFormatStyle. Use when replacing legacy Formatter subclasses, designing reusable format APIs, using SwiftUI Text(_:format:), correcting availability, or testing user-facing formatted output across locales.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Swift FormatStyle

Use Foundation's type-safe `FormatStyle` APIs for user-facing display and `ParseableFormatStyle` when the same convention must accept input. Route String Catalogs, plurals, localized copy, bundles, and RTL layout to `ios-localization`; formatting still requires locale review even when no text is translated.

## Contents

- [Workflow](#workflow)
- [Quick Reference](#quick-reference)
- [Selection and Availability](#selection-and-availability)
- [Parsing](#parsing)
- [SwiftUI Integration](#swiftui-integration)
- [Custom FormatStyle](#custom-formatstyle)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)

## Workflow

1. Identify the value's semantic type and whether output is display-only or must round-trip through parsing.
2. Select the narrowest built-in style and keep the user's current locale unless a wire format explicitly requires another locale.
3. Render the exact UI with representative locales such as `en_US`, `de_DE`, `ar_SA`, and `ja_JP`.
4. Check separators, numbering systems, calendars, currency and unit conventions, text direction, and layout.
5. If output or parsing fails, fix the style or surrounding copy, restore the input fixture, and rerun the same locale matrix.

Load [FormatStyle Recipes](references/formatstyle-recipes.md) when implementation needs concrete modifiers, date intervals, relative dates, duration patterns, measurements, names, lists, byte counts, or URL component controls.

## Quick Reference

The rest: https://github.com/dpearson2699/swift-ios-skills/blob/HEAD/skills/swift-formatstyle/SKILL.md
