SwiftCurrency

Type-safety and algorithms for working with money in Swift.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

84

Maintenance

Last Commit

6mos ago

Contributors

3

Package

Dependencies

0

License

MIT

Categories

Readme

Swift Currency

MIT License Swift 5+

Package Tests codecov

Documentation Maintainability

Introduction

Swift Currency provides type-safe representations of ISO 4217 currencies in Swift.

It provides many conveniences for working with currencies, such as literal representations, string interpolation, and mathematics.

import Currency
import Foundation

let dollars = USD(30.01)
print(dollars)
// 30.01 USD
print(dollars * 2)
// 60.02 USD
print(dollars.distributedEvenly(intoParts: 6))
// [USD(1.68), USD(1.68), USD(1.68), USD(1.67), USD(1.67), USD(1.67)]

let pounds = GBP(109.23)
print(dollars + pounds)
// compile error

let jpy: JPY = 399
print("The total price is \(jpy.localizedString()).")
// "The total price is ¥399.", assuming `Foundation.Locale.current` is "en_US"

let euro = EUR(29.09)
print("Der Gesamtpreis beträgt \(localize: euro, for: .init(identifier: "de_DE")).")
// "Der Gesamtpreis beträgt 29,09 €."

For more detailed examples, see the usage guide.

Language and Platform Test Matrix

The following table shows the combination of Swift language versions and operating systems that receive regular unit testing.

PlatformSwift 55.15.2Trunk
macOS Latest
Ubuntu 18.04 (Bionic)
Ubuntu 16.04 (Xenial)

Installing

Swift Package Manager

The preferred installation method is with SPM. Just add the package reference to your Package.swift.

dependencies: [
    .package(url: "https://github.com/peek-travel/swift-currency", from: "0.6.0")
]

Carthage

To install with Carthage, just add the line gh "https://github.com/peek-travel/swift-currency" ~> 0.6.0 to your Cartfile.

Cocoapods

To install with CocoaPods, just add the line pod 'SwiftCurrency', '~> 0.6.0' to your Podfile.

Documentation

The API docs for the latest tagged release are always available at peek-travel.github.io/swift-currency.

For "how to use" guides, and additional information about the project, see the documentation.

Questions

For bugs or feature requests, file a new issue.

Changelog

SemVer changes are documented for each release on the releases page.

Contributing

Check out CONTRIBUTING.md for more information on how to help with SwiftCurrency.

Contributors

Check out CONTRIBUTORS.txt to see the full list. This list is updated for each release.

License

MIT

Copyright (c) 2020-present, Peek Travel Inc.

This project contains code written by others not affliated with this project. All copyright claims are reserved by them. For a full list, with their claimed rights, see NOTICE.txt

Swift is a registered trademark of Apple, Inc. Any use of their trademark does not imply any affiliation with or endorsement by them, and all rights are reserved by them.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100