# malcommac/swiftdate architecture

> Architecture diagram of the GitHub repository malcommac/swiftdate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/malcommac/swiftdate
- Repository: https://github.com/malcommac/swiftdate

## Overview

SwiftDate is a Swift date-and-time toolkit. Its central workflow parses a string or constructs a date, represents it with a calendar/time-zone/locale region, applies date operations, then compares or formats the result. The repository also documents date enumeration, Codable support, random generation, and time-period management. Parsing and several APIs are evidenced by sampled source; some capability links rely on README descriptions and the file tree, so uncertain call wiring is omitted.

Main entry points: [`Sources/SwiftDate/DateInRegion/DateInRegion.swift`](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion.swift) (Regional date), [`Sources/SwiftDate/Foundation+Extras/String+Parser.swift`](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Foundation%2BExtras/String%2BParser.swift) (String parsing), [`Sources/SwiftDate/Formatters/Formatter+Protocols.swift`](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/Formatter%2BProtocols.swift) (Formatter styles), [`Sources/SwiftDate/Formatters/ISOParser.swift`](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/ISOParser.swift) (ISO parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_construction["Parsing and creation"]
  node_string_parse["String parsing"]
  node_iso_parser["ISO parser<br/>[ISOParser.swift]"]
  node_dotnet_parser[".NET parser"]
  node_date_create["Date creation"]
  node_date_enumerate["Enumeration and random"]
end

subgraph group_date_api["Date operations"]
  node_date_region["Regional date<br/>[DateInRegion.swift]"]
  node_region["Region settings<br/>[Region.swift]"]
  node_date_base["Foundation date<br/>[Date.swift]"]
  node_representable["Date interface"]
  node_date_components["Component access"]
  node_date_math["Date manipulation"]
  node_date_compare["Date comparison"]
  node_plain_date_math["Foundation date operations<br/>[Date+Math.swift]"]
  node_plain_date_compare["Foundation date comparison<br/>[Date+Compare.swift]"]
end

subgraph group_formatting["Formatting and support"]
  node_formatter_protocols["Formatter styles"]
  node_iso_formatter["ISO formatting<br/>[ISOFormatter.swift]"]
  node_dotnet_formatter[".NET formatting"]
  node_locale_support["Locale support<br/>[Locales.swift]"]
end

subgraph group_periods["Time periods"]
  node_time_period["Time period<br/>[TimePeriod.swift]"]
  node_period_rules["Period operations"]
  node_period_groups["Period collections"]
  node_period_chain["Period chains"]
end

node_user(("Library user"))

node_user -->|"parses text"| node_string_parse
node_user -->|"creates dates"| node_date_create
node_string_parse -->|"dispatches ISO"| node_iso_parser
node_string_parse -->|"dispatches .NET"| node_dotnet_parser
node_string_parse -->|"constructs date"| node_date_region
node_iso_parser -->|"produces parsed date"| node_date_region
node_dotnet_parser -->|"produces parsed date"| node_date_region
node_date_create -->|"creates regional date"| node_date_region
node_date_region -->|"uses settings"| node_region
node_user -->|"extracts components"| node_date_components
node_user -->|"manipulates date"| node_date_math
node_user -->|"compares dates"| node_date_compare
node_user -->|"enumerates dates"| node_date_enumerate
node_user -->|"manipulates date"| node_plain_date_math
node_user -->|"compares dates"| node_plain_date_compare
node_user -->|"formats date"| node_formatter_protocols
node_formatter_protocols -->|"formats ISO"| node_iso_formatter
node_formatter_protocols -->|"formats .NET"| node_dotnet_formatter
node_date_region -->|"uses locale"| node_locale_support
node_user -->|"creates periods"| node_time_period
node_time_period -->|"uses period rules"| node_period_rules
node_user -->|"manages periods"| node_period_groups
node_user -->|"chains periods"| node_period_chain

click node_string_parse "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Foundation%2BExtras/String%2BParser.swift"
click node_iso_parser "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/ISOParser.swift"
click node_dotnet_parser "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/DotNetParserFormatter.swift"
click node_date_create "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BCreate.swift"
click node_date_region "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion.swift"
click node_region "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/Region.swift"
click node_date_base "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Date/Date.swift"
click node_representable "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateRepresentable.swift"
click node_date_components "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BComponents.swift"
click node_date_math "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BMath.swift"
click node_date_compare "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BCompare.swift"
click node_date_enumerate "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BCreate.swift"
click node_plain_date_math "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Date/Date%2BMath.swift"
click node_plain_date_compare "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Date/Date%2BCompare.swift"
click node_formatter_protocols "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/Formatter%2BProtocols.swift"
click node_iso_formatter "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/ISOFormatter.swift"
click node_dotnet_formatter "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/DotNetParserFormatter.swift"
click node_locale_support "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Supports/Locales.swift"
click node_time_period "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/TimePeriod/TimePeriod.swift"
click node_period_rules "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/TimePeriod/TimePeriodProtocol.swift"
click node_period_groups "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/TimePeriod/Groups/TimePeriodCollection.swift"
click node_period_chain "https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/TimePeriod/Groups/TimePeriodChain.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_string_parse,node_iso_parser,node_dotnet_parser,node_date_create,node_date_enumerate,node_user toneBlue
class node_date_region,node_region,node_date_base,node_representable,node_date_components,node_date_math,node_date_compare,node_plain_date_math,node_plain_date_compare toneAmber
class node_formatter_protocols,node_iso_formatter,node_dotnet_formatter,node_locale_support toneMint
class node_time_period,node_period_rules,node_period_groups,node_period_chain toneRose
```

## Components

### Parsing and creation

- [String parsing](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Foundation%2BExtras/String%2BParser.swift): `Sources/SwiftDate/Foundation+Extras/String+Parser.swift`
- [ISO parser](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/ISOParser.swift): `Sources/SwiftDate/Formatters/ISOParser.swift`
- [.NET parser](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/DotNetParserFormatter.swift): `Sources/SwiftDate/Formatters/DotNetParserFormatter.swift`
- [Date creation](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BCreate.swift): `Sources/SwiftDate/DateInRegion/DateInRegion+Create.swift`
- [Enumeration and random](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BCreate.swift): `Sources/SwiftDate/DateInRegion/DateInRegion+Create.swift`

### Date operations

- [Regional date](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion.swift): `Sources/SwiftDate/DateInRegion/DateInRegion.swift`
- [Region settings](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/Region.swift): `Sources/SwiftDate/DateInRegion/Region.swift`
- [Foundation date](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Date/Date.swift): `Sources/SwiftDate/Date/Date.swift`
- [Date interface](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateRepresentable.swift): `Sources/SwiftDate/DateRepresentable.swift`
- [Component access](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BComponents.swift): `Sources/SwiftDate/DateInRegion/DateInRegion+Components.swift`
- [Date manipulation](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BMath.swift): `Sources/SwiftDate/DateInRegion/DateInRegion+Math.swift`
- [Date comparison](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/DateInRegion/DateInRegion%2BCompare.swift): `Sources/SwiftDate/DateInRegion/DateInRegion+Compare.swift`
- [Foundation date operations](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Date/Date%2BMath.swift): `Sources/SwiftDate/Date/Date+Math.swift`
- [Foundation date comparison](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Date/Date%2BCompare.swift): `Sources/SwiftDate/Date/Date+Compare.swift`

### Formatting and support

- [Formatter styles](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/Formatter%2BProtocols.swift): `Sources/SwiftDate/Formatters/Formatter+Protocols.swift`
- [ISO formatting](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/ISOFormatter.swift): `Sources/SwiftDate/Formatters/ISOFormatter.swift`
- [.NET formatting](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Formatters/DotNetParserFormatter.swift): `Sources/SwiftDate/Formatters/DotNetParserFormatter.swift`
- [Locale support](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/Supports/Locales.swift): `Sources/SwiftDate/Supports/Locales.swift`

### Time periods

- [Time period](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/TimePeriod/TimePeriod.swift): `Sources/SwiftDate/TimePeriod/TimePeriod.swift`
- [Period operations](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/TimePeriod/TimePeriodProtocol.swift): `Sources/SwiftDate/TimePeriod/TimePeriodProtocol.swift`
- [Period collections](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/TimePeriod/Groups/TimePeriodCollection.swift): `Sources/SwiftDate/TimePeriod/Groups/TimePeriodCollection.swift`
- [Period chains](https://github.com/malcommac/swiftdate/blob/master/Sources/SwiftDate/TimePeriod/Groups/TimePeriodChain.swift): `Sources/SwiftDate/TimePeriod/Groups/TimePeriodChain.swift`

### Other components

- **Library user**

## Connections

- Library user → String parsing: parses text
- Library user → Date creation: creates dates
- String parsing → ISO parser: dispatches ISO
- String parsing → .NET parser: dispatches .NET
- String parsing → Regional date: constructs date
- ISO parser → Regional date: produces parsed date
- .NET parser → Regional date: produces parsed date
- Date creation → Regional date: creates regional date
- Regional date → Region settings: uses settings
- Library user → Component access: extracts components
- Library user → Date manipulation: manipulates date
- Library user → Date comparison: compares dates
- Library user → Enumeration and random: enumerates dates
- Library user → Foundation date operations: manipulates date
- Library user → Foundation date comparison: compares dates
- Library user → Formatter styles: formats date
- Formatter styles → ISO formatting: formats ISO
- Formatter styles → .NET formatting: formats .NET
- Regional date → Locale support: uses locale
- Library user → Time period: creates periods
- Time period → Period operations: uses period rules
- Library user → Period collections: manages periods
- Library user → Period chains: chains periods
