-
Notifications
You must be signed in to change notification settings - Fork 1
/
std.swift
386 lines (379 loc) · 19 KB
/
std.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
import UIKit
struct Currency {
/// The `ISO 4217` currency code
var code: String
/// The number of digits to display after the decimal point when displaying the currency
var minorUnits: Int
/// The factor to divide the currency figure by before handing to a currency formatter
var factor: Int
}
class Currencies {
static let AED: Currency = Currency(code: "AED", minorUnits: 2, factor: 100)
static let AFN: Currency = Currency(code: "AFN", minorUnits: 2, factor: 100)
static let ALL: Currency = Currency(code: "ALL", minorUnits: 2, factor: 100)
static let AMD: Currency = Currency(code: "AMD", minorUnits: 2, factor: 100)
static let ANG: Currency = Currency(code: "ANG", minorUnits: 2, factor: 100)
static let AOA: Currency = Currency(code: "AOA", minorUnits: 2, factor: 100)
static let ARS: Currency = Currency(code: "ARS", minorUnits: 2, factor: 100)
static let AUD: Currency = Currency(code: "AUD", minorUnits: 2, factor: 100)
static let AWG: Currency = Currency(code: "AWG", minorUnits: 2, factor: 100)
static let AZN: Currency = Currency(code: "AZN", minorUnits: 2, factor: 100)
static let BAM: Currency = Currency(code: "BAM", minorUnits: 2, factor: 100)
static let BBD: Currency = Currency(code: "BBD", minorUnits: 2, factor: 100)
static let BDT: Currency = Currency(code: "BDT", minorUnits: 2, factor: 100)
static let BGN: Currency = Currency(code: "BGN", minorUnits: 2, factor: 100)
static let BHD: Currency = Currency(code: "BHD", minorUnits: 3, factor: 1000)
static let BIF: Currency = Currency(code: "BIF", minorUnits: 0, factor: 1)
static let BMD: Currency = Currency(code: "BMD", minorUnits: 2, factor: 100)
static let BND: Currency = Currency(code: "BND", minorUnits: 2, factor: 100)
static let BOB: Currency = Currency(code: "BOB", minorUnits: 2, factor: 100)
static let BOV: Currency = Currency(code: "BOV", minorUnits: 2, factor: 100)
static let BRL: Currency = Currency(code: "BRL", minorUnits: 2, factor: 100)
static let BSD: Currency = Currency(code: "BSD", minorUnits: 2, factor: 100)
static let BTN: Currency = Currency(code: "BTN", minorUnits: 2, factor: 100)
static let BWP: Currency = Currency(code: "BWP", minorUnits: 2, factor: 100)
static let BYN: Currency = Currency(code: "BYN", minorUnits: 2, factor: 100)
static let BZD: Currency = Currency(code: "BZD", minorUnits: 2, factor: 100)
static let CAD: Currency = Currency(code: "CAD", minorUnits: 2, factor: 100)
static let CDF: Currency = Currency(code: "CDF", minorUnits: 2, factor: 100)
static let CHE: Currency = Currency(code: "CHE", minorUnits: 2, factor: 100)
static let CHF: Currency = Currency(code: "CHF", minorUnits: 2, factor: 100)
static let CHW: Currency = Currency(code: "CHW", minorUnits: 2, factor: 100)
static let CLF: Currency = Currency(code: "CLF", minorUnits: 4, factor: 10000)
static let CLP: Currency = Currency(code: "CLP", minorUnits: 0, factor: 1)
static let CNY: Currency = Currency(code: "CNY", minorUnits: 2, factor: 100)
static let COP: Currency = Currency(code: "COP", minorUnits: 2, factor: 100)
static let COU: Currency = Currency(code: "COU", minorUnits: 2, factor: 100)
static let CRC: Currency = Currency(code: "CRC", minorUnits: 2, factor: 100)
static let CUC: Currency = Currency(code: "CUC", minorUnits: 2, factor: 100)
static let CUP: Currency = Currency(code: "CUP", minorUnits: 2, factor: 100)
static let CVE: Currency = Currency(code: "CVE", minorUnits: 2, factor: 100)
static let CZK: Currency = Currency(code: "CZK", minorUnits: 2, factor: 100)
static let DJF: Currency = Currency(code: "DJF", minorUnits: 0, factor: 1)
static let DKK: Currency = Currency(code: "DKK", minorUnits: 2, factor: 100)
static let DOP: Currency = Currency(code: "DOP", minorUnits: 2, factor: 100)
static let DZD: Currency = Currency(code: "DZD", minorUnits: 2, factor: 100)
static let EGP: Currency = Currency(code: "EGP", minorUnits: 2, factor: 100)
static let ERN: Currency = Currency(code: "ERN", minorUnits: 2, factor: 100)
static let ETB: Currency = Currency(code: "ETB", minorUnits: 2, factor: 100)
static let EUR: Currency = Currency(code: "EUR", minorUnits: 2, factor: 100)
static let FJD: Currency = Currency(code: "FJD", minorUnits: 2, factor: 100)
static let FKP: Currency = Currency(code: "FKP", minorUnits: 2, factor: 100)
static let GBP: Currency = Currency(code: "GBP", minorUnits: 2, factor: 100)
static let GEL: Currency = Currency(code: "GEL", minorUnits: 2, factor: 100)
static let GHS: Currency = Currency(code: "GHS", minorUnits: 2, factor: 100)
static let GIP: Currency = Currency(code: "GIP", minorUnits: 2, factor: 100)
static let GMD: Currency = Currency(code: "GMD", minorUnits: 2, factor: 100)
static let GNF: Currency = Currency(code: "GNF", minorUnits: 0, factor: 1)
static let GTQ: Currency = Currency(code: "GTQ", minorUnits: 2, factor: 100)
static let GYD: Currency = Currency(code: "GYD", minorUnits: 2, factor: 100)
static let HKD: Currency = Currency(code: "HKD", minorUnits: 2, factor: 100)
static let HNL: Currency = Currency(code: "HNL", minorUnits: 2, factor: 100)
static let HTG: Currency = Currency(code: "HTG", minorUnits: 2, factor: 100)
static let HUF: Currency = Currency(code: "HUF", minorUnits: 2, factor: 100)
static let IDR: Currency = Currency(code: "IDR", minorUnits: 2, factor: 100)
static let ILS: Currency = Currency(code: "ILS", minorUnits: 2, factor: 100)
static let INR: Currency = Currency(code: "INR", minorUnits: 2, factor: 100)
static let IQD: Currency = Currency(code: "IQD", minorUnits: 3, factor: 1000)
static let IRR: Currency = Currency(code: "IRR", minorUnits: 2, factor: 100)
static let ISK: Currency = Currency(code: "ISK", minorUnits: 0, factor: 1)
static let JMD: Currency = Currency(code: "JMD", minorUnits: 2, factor: 100)
static let JOD: Currency = Currency(code: "JOD", minorUnits: 3, factor: 1000)
static let JPY: Currency = Currency(code: "JPY", minorUnits: 0, factor: 1)
static let KES: Currency = Currency(code: "KES", minorUnits: 2, factor: 100)
static let KGS: Currency = Currency(code: "KGS", minorUnits: 2, factor: 100)
static let KHR: Currency = Currency(code: "KHR", minorUnits: 2, factor: 100)
static let KMF: Currency = Currency(code: "KMF", minorUnits: 0, factor: 1)
static let KPW: Currency = Currency(code: "KPW", minorUnits: 2, factor: 100)
static let KRW: Currency = Currency(code: "KRW", minorUnits: 0, factor: 1)
static let KWD: Currency = Currency(code: "KWD", minorUnits: 3, factor: 1000)
static let KYD: Currency = Currency(code: "KYD", minorUnits: 2, factor: 100)
static let KZT: Currency = Currency(code: "KZT", minorUnits: 2, factor: 100)
static let LAK: Currency = Currency(code: "LAK", minorUnits: 2, factor: 100)
static let LBP: Currency = Currency(code: "LBP", minorUnits: 2, factor: 100)
static let LKR: Currency = Currency(code: "LKR", minorUnits: 2, factor: 100)
static let LRD: Currency = Currency(code: "LRD", minorUnits: 2, factor: 100)
static let LSL: Currency = Currency(code: "LSL", minorUnits: 2, factor: 100)
static let LYD: Currency = Currency(code: "LYD", minorUnits: 3, factor: 1000)
static let MAD: Currency = Currency(code: "MAD", minorUnits: 2, factor: 100)
static let MDL: Currency = Currency(code: "MDL", minorUnits: 2, factor: 100)
static let MGA: Currency = Currency(code: "MGA", minorUnits: 2, factor: 100)
static let MKD: Currency = Currency(code: "MKD", minorUnits: 2, factor: 100)
static let MMK: Currency = Currency(code: "MMK", minorUnits: 2, factor: 100)
static let MNT: Currency = Currency(code: "MNT", minorUnits: 2, factor: 100)
static let MOP: Currency = Currency(code: "MOP", minorUnits: 2, factor: 100)
static let MRU: Currency = Currency(code: "MRU", minorUnits: 2, factor: 100)
static let MUR: Currency = Currency(code: "MUR", minorUnits: 2, factor: 100)
static let MVR: Currency = Currency(code: "MVR", minorUnits: 2, factor: 100)
static let MWK: Currency = Currency(code: "MWK", minorUnits: 2, factor: 100)
static let MXN: Currency = Currency(code: "MXN", minorUnits: 2, factor: 100)
static let MXV: Currency = Currency(code: "MXV", minorUnits: 2, factor: 100)
static let MYR: Currency = Currency(code: "MYR", minorUnits: 2, factor: 100)
static let MZN: Currency = Currency(code: "MZN", minorUnits: 2, factor: 100)
static let NAD: Currency = Currency(code: "NAD", minorUnits: 2, factor: 100)
static let NGN: Currency = Currency(code: "NGN", minorUnits: 2, factor: 100)
static let NIO: Currency = Currency(code: "NIO", minorUnits: 2, factor: 100)
static let NOK: Currency = Currency(code: "NOK", minorUnits: 2, factor: 100)
static let NPR: Currency = Currency(code: "NPR", minorUnits: 2, factor: 100)
static let NZD: Currency = Currency(code: "NZD", minorUnits: 2, factor: 100)
static let OMR: Currency = Currency(code: "OMR", minorUnits: 3, factor: 1000)
static let PAB: Currency = Currency(code: "PAB", minorUnits: 2, factor: 100)
static let PEN: Currency = Currency(code: "PEN", minorUnits: 2, factor: 100)
static let PGK: Currency = Currency(code: "PGK", minorUnits: 2, factor: 100)
static let PHP: Currency = Currency(code: "PHP", minorUnits: 2, factor: 100)
static let PKR: Currency = Currency(code: "PKR", minorUnits: 2, factor: 100)
static let PLN: Currency = Currency(code: "PLN", minorUnits: 2, factor: 100)
static let PYG: Currency = Currency(code: "PYG", minorUnits: 0, factor: 1)
static let QAR: Currency = Currency(code: "QAR", minorUnits: 2, factor: 100)
static let RON: Currency = Currency(code: "RON", minorUnits: 2, factor: 100)
static let RSD: Currency = Currency(code: "RSD", minorUnits: 2, factor: 100)
static let RUB: Currency = Currency(code: "RUB", minorUnits: 2, factor: 100)
static let RWF: Currency = Currency(code: "RWF", minorUnits: 0, factor: 1)
static let SAR: Currency = Currency(code: "SAR", minorUnits: 2, factor: 100)
static let SBD: Currency = Currency(code: "SBD", minorUnits: 2, factor: 100)
static let SCR: Currency = Currency(code: "SCR", minorUnits: 2, factor: 100)
static let SDG: Currency = Currency(code: "SDG", minorUnits: 2, factor: 100)
static let SEK: Currency = Currency(code: "SEK", minorUnits: 2, factor: 100)
static let SGD: Currency = Currency(code: "SGD", minorUnits: 2, factor: 100)
static let SHP: Currency = Currency(code: "SHP", minorUnits: 2, factor: 100)
static let SLE: Currency = Currency(code: "SLE", minorUnits: 2, factor: 100)
static let SOS: Currency = Currency(code: "SOS", minorUnits: 2, factor: 100)
static let SRD: Currency = Currency(code: "SRD", minorUnits: 2, factor: 100)
static let SSP: Currency = Currency(code: "SSP", minorUnits: 2, factor: 100)
static let STN: Currency = Currency(code: "STN", minorUnits: 2, factor: 100)
static let SVC: Currency = Currency(code: "SVC", minorUnits: 2, factor: 100)
static let SYP: Currency = Currency(code: "SYP", minorUnits: 2, factor: 100)
static let SZL: Currency = Currency(code: "SZL", minorUnits: 2, factor: 100)
static let THB: Currency = Currency(code: "THB", minorUnits: 2, factor: 100)
static let TJS: Currency = Currency(code: "TJS", minorUnits: 2, factor: 100)
static let TMT: Currency = Currency(code: "TMT", minorUnits: 2, factor: 100)
static let TND: Currency = Currency(code: "TND", minorUnits: 3, factor: 1000)
static let TOP: Currency = Currency(code: "TOP", minorUnits: 2, factor: 100)
static let TRY: Currency = Currency(code: "TRY", minorUnits: 2, factor: 100)
static let TTD: Currency = Currency(code: "TTD", minorUnits: 2, factor: 100)
static let TWD: Currency = Currency(code: "TWD", minorUnits: 2, factor: 100)
static let TZS: Currency = Currency(code: "TZS", minorUnits: 2, factor: 100)
static let UAH: Currency = Currency(code: "UAH", minorUnits: 2, factor: 100)
static let UGX: Currency = Currency(code: "UGX", minorUnits: 0, factor: 1)
static let USD: Currency = Currency(code: "USD", minorUnits: 2, factor: 100)
static let USN: Currency = Currency(code: "USN", minorUnits: 2, factor: 100)
static let UYI: Currency = Currency(code: "UYI", minorUnits: 0, factor: 1)
static let UYU: Currency = Currency(code: "UYU", minorUnits: 2, factor: 100)
static let UYW: Currency = Currency(code: "UYW", minorUnits: 4, factor: 10000)
static let UZS: Currency = Currency(code: "UZS", minorUnits: 2, factor: 100)
static let VED: Currency = Currency(code: "VED", minorUnits: 2, factor: 100)
static let VES: Currency = Currency(code: "VES", minorUnits: 2, factor: 100)
static let VND: Currency = Currency(code: "VND", minorUnits: 0, factor: 1)
static let VUV: Currency = Currency(code: "VUV", minorUnits: 0, factor: 1)
static let WST: Currency = Currency(code: "WST", minorUnits: 2, factor: 100)
static let XAF: Currency = Currency(code: "XAF", minorUnits: 0, factor: 1)
static let XAG: Currency = Currency(code: "XAG", minorUnits: 0, factor: 1)
static let XAU: Currency = Currency(code: "XAU", minorUnits: 0, factor: 1)
static let XBA: Currency = Currency(code: "XBA", minorUnits: 0, factor: 1)
static let XBB: Currency = Currency(code: "XBB", minorUnits: 0, factor: 1)
static let XBC: Currency = Currency(code: "XBC", minorUnits: 0, factor: 1)
static let XBD: Currency = Currency(code: "XBD", minorUnits: 0, factor: 1)
static let XCD: Currency = Currency(code: "XCD", minorUnits: 2, factor: 100)
static let XDR: Currency = Currency(code: "XDR", minorUnits: 0, factor: 1)
static let XOF: Currency = Currency(code: "XOF", minorUnits: 0, factor: 1)
static let XPD: Currency = Currency(code: "XPD", minorUnits: 0, factor: 1)
static let XPF: Currency = Currency(code: "XPF", minorUnits: 0, factor: 1)
static let XPT: Currency = Currency(code: "XPT", minorUnits: 0, factor: 1)
static let XSU: Currency = Currency(code: "XSU", minorUnits: 0, factor: 1)
static let XTS: Currency = Currency(code: "XTS", minorUnits: 0, factor: 1)
static let XUA: Currency = Currency(code: "XUA", minorUnits: 0, factor: 1)
static let XXX: Currency = Currency(code: "XXX", minorUnits: 0, factor: 1)
static let YER: Currency = Currency(code: "YER", minorUnits: 2, factor: 100)
static let ZAR: Currency = Currency(code: "ZAR", minorUnits: 2, factor: 100)
static let ZMW: Currency = Currency(code: "ZMW", minorUnits: 2, factor: 100)
static let ZWL: Currency = Currency(code: "ZWL", minorUnits: 2, factor: 100)
static let allCurrencies: [String: Currency] =
[
"AED": AED,
"AFN": AFN,
"ALL": ALL,
"AMD": AMD,
"ANG": ANG,
"AOA": AOA,
"ARS": ARS,
"AUD": AUD,
"AWG": AWG,
"AZN": AZN,
"BAM": BAM,
"BBD": BBD,
"BDT": BDT,
"BGN": BGN,
"BHD": BHD,
"BIF": BIF,
"BMD": BMD,
"BND": BND,
"BOB": BOB,
"BOV": BOV,
"BRL": BRL,
"BSD": BSD,
"BTN": BTN,
"BWP": BWP,
"BYN": BYN,
"BZD": BZD,
"CAD": CAD,
"CDF": CDF,
"CHE": CHE,
"CHF": CHF,
"CHW": CHW,
"CLF": CLF,
"CLP": CLP,
"CNY": CNY,
"COP": COP,
"COU": COU,
"CRC": CRC,
"CUC": CUC,
"CUP": CUP,
"CVE": CVE,
"CZK": CZK,
"DJF": DJF,
"DKK": DKK,
"DOP": DOP,
"DZD": DZD,
"EGP": EGP,
"ERN": ERN,
"ETB": ETB,
"EUR": EUR,
"FJD": FJD,
"FKP": FKP,
"GBP": GBP,
"GEL": GEL,
"GHS": GHS,
"GIP": GIP,
"GMD": GMD,
"GNF": GNF,
"GTQ": GTQ,
"GYD": GYD,
"HKD": HKD,
"HNL": HNL,
"HTG": HTG,
"HUF": HUF,
"IDR": IDR,
"ILS": ILS,
"INR": INR,
"IQD": IQD,
"IRR": IRR,
"ISK": ISK,
"JMD": JMD,
"JOD": JOD,
"JPY": JPY,
"KES": KES,
"KGS": KGS,
"KHR": KHR,
"KMF": KMF,
"KPW": KPW,
"KRW": KRW,
"KWD": KWD,
"KYD": KYD,
"KZT": KZT,
"LAK": LAK,
"LBP": LBP,
"LKR": LKR,
"LRD": LRD,
"LSL": LSL,
"LYD": LYD,
"MAD": MAD,
"MDL": MDL,
"MGA": MGA,
"MKD": MKD,
"MMK": MMK,
"MNT": MNT,
"MOP": MOP,
"MRU": MRU,
"MUR": MUR,
"MVR": MVR,
"MWK": MWK,
"MXN": MXN,
"MXV": MXV,
"MYR": MYR,
"MZN": MZN,
"NAD": NAD,
"NGN": NGN,
"NIO": NIO,
"NOK": NOK,
"NPR": NPR,
"NZD": NZD,
"OMR": OMR,
"PAB": PAB,
"PEN": PEN,
"PGK": PGK,
"PHP": PHP,
"PKR": PKR,
"PLN": PLN,
"PYG": PYG,
"QAR": QAR,
"RON": RON,
"RSD": RSD,
"RUB": RUB,
"RWF": RWF,
"SAR": SAR,
"SBD": SBD,
"SCR": SCR,
"SDG": SDG,
"SEK": SEK,
"SGD": SGD,
"SHP": SHP,
"SLE": SLE,
"SOS": SOS,
"SRD": SRD,
"SSP": SSP,
"STN": STN,
"SVC": SVC,
"SYP": SYP,
"SZL": SZL,
"THB": THB,
"TJS": TJS,
"TMT": TMT,
"TND": TND,
"TOP": TOP,
"TRY": TRY,
"TTD": TTD,
"TWD": TWD,
"TZS": TZS,
"UAH": UAH,
"UGX": UGX,
"USD": USD,
"USN": USN,
"UYI": UYI,
"UYU": UYU,
"UYW": UYW,
"UZS": UZS,
"VED": VED,
"VES": VES,
"VND": VND,
"VUV": VUV,
"WST": WST,
"XAF": XAF,
"XAG": XAG,
"XAU": XAU,
"XBA": XBA,
"XBB": XBB,
"XBC": XBC,
"XBD": XBD,
"XCD": XCD,
"XDR": XDR,
"XOF": XOF,
"XPD": XPD,
"XPF": XPF,
"XPT": XPT,
"XSU": XSU,
"XTS": XTS,
"XUA": XUA,
"XXX": XXX,
"YER": YER,
"ZAR": ZAR,
"ZMW": ZMW,
"ZWL": ZWL
]
/// Look up a currency struct containing currency and formatting information
///
/// - Parameter code: The `ISO 4217` currency code to search for
/// - Returns: A `Currency` object, if supported. Otherwise nil.
class func currency(for code: String) -> Currency? {
return allCurrencies[code]
}
}