-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de4864f
commit f42f0bb
Showing
257 changed files
with
12,214 additions
and
2,965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Copyright (c) 2017 Adyen B.V. | ||
// | ||
// This file is open source and available under the MIT license. See the LICENSE file for more info. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Convenience class to format a number with a given currency. | ||
internal class CurrencyFormatter { | ||
|
||
internal static func format(_ amount: Int, currencyCode: String) -> String? { | ||
currencyFormatter.currencyCode = currencyCode | ||
|
||
let maximumFractionDigits = currencyFormatter.maximumFractionDigits | ||
let decimalMinorAmount = NSDecimalNumber(value: amount) | ||
let convertedAmount = decimalMinorAmount.multiplying(byPowerOf10: Int16(-maximumFractionDigits)).doubleValue | ||
|
||
let number = NSNumber(value: convertedAmount) | ||
|
||
return currencyFormatter.string(from: number) | ||
} | ||
|
||
private static let currencyFormatter: NumberFormatter = { | ||
let currencyFormatter = NumberFormatter() | ||
currencyFormatter.numberStyle = .currency | ||
|
||
return currencyFormatter | ||
}() | ||
|
||
private init() { | ||
|
||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.