SettlementDateProvider

Package Overview

SettlementDateProvider is a Swift package designed to caluclate and provide accurate settlement dates by considering country-specific bank holidays and weekends.

The package includes embedded holiday rules for supported countries, ensuring that payments and other financial transactions are processed on valid business days without requiring external configuration.

Installation

To add SettlementDateProvider to your project, include it in your Package.swift file:

dependencies: [
    .package(url: "https://github.com/msuzoagu/SettlementDateProvider.git", from: "1.0.0")
]

You can also use Xcode's GUI to add the package dependency

Sample Usage

import SettlementDateProvider

let strategy: SettlementStrategy = .restrictive
let provider = try SettlementDateFactory().provider(
    for: "US",
    using: strategy,
    given: [Date()]
)
let settlementDates = provider.settlementDates
import SettlementDateProvider

let provider = try SettlementDateFactory().provider(
    for: "US",
    given: [Date()]
)
let settlementDates = provider.settlementDates

Getting Started

To use SettlementDateProvider, you need to provide:

  • a country code
    • where - country code must be iSO 3166-1 alpha 2 format
  • a date list
    • where date list is [Date] you want to generate settlement dates
  • a settlement strategy
    • SettlementDateProvider offers flexible strategies for determining the settlement date viaSettlementStrategy enum:
      • permissive: selects closest previous valid business day before reference date
      • restrictive: selects next valid business day after reference date

SettlementStrategy defaults to .permissive

Supported Countries

  • United States
    • iSO 3166-1 alpha 2 format "US"