commit e4d886798a108d4fa1408ecdd85ec2febc1022ce
parent 491ab05d3a0854d9a6a8991b34d06e037dfc7ea9
Author: Marc Stibane <marc@taler.net>
Date: Thu, 18 Jul 2024 10:46:43 +0200
Added name & symbol
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/taler-swift/Sources/taler-swift/Amount.swift b/taler-swift/Sources/taler-swift/Amount.swift
@@ -77,6 +77,18 @@ public final class Amount: Codable, Hashable, @unchecked Sendable, CustomStringC
currency = newCurrency
}
+ /// Name & symbol{s) of the currency of the amount. Cannot be changed later, except...
+ private var currencyNm: String?
+ private var currencySmbls: [Int : String]?
+
+ /// ... with these functions
+ public func setCurrencyName(_ newCurrency: String) {
+ currencyNm = newCurrency
+ }
+ public func setCurrencySymbols(_ newCurrency: [Int : String]) {
+ currencySmbls = newCurrency
+ }
+
/// The integer value of the amount (number to the left of the decimal point).
var integer: UInt64
@@ -178,6 +190,12 @@ public final class Amount: Codable, Hashable, @unchecked Sendable, CustomStringC
public var currencyStr: String {
currency
}
+ public var currencyName: String {
+ currencyNm ?? currency
+ }
+ public var currencySymbol: String {
+ currencySmbls?[0] ?? currency
+ }
/// The string representation of the amount, formatted as "`currency`:`integer`.`fraction`" (without space).
public var description: String {