-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from peek-travel/initial-implementation
Initial implementation
- Loading branch information
Showing
15 changed files
with
3,552 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
// swift-tools-version:5.1 | ||
// swift-tools-version:5.0 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Currency", | ||
name: "swift-currency", | ||
products: [ | ||
// Products define the executables and libraries produced by a package, and make them visible to other packages. | ||
.library( | ||
name: "Currency", | ||
targets: ["Currency"]), | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
.library(name: "Currency", targets: ["Currency"]), | ||
], | ||
dependencies: [], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages which this package depends on. | ||
.target( | ||
name: "Currency", | ||
dependencies: []), | ||
.testTarget( | ||
name: "CurrencyTests", | ||
dependencies: ["Currency"]), | ||
.target(name: "Currency", dependencies: []), | ||
.testTarget(name: "CurrencyTests", dependencies: ["Currency"]), | ||
] | ||
) |
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 |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# Currency | ||
|
||
A description of this package. | ||
|
||
## ISO 4271 Currency List | ||
|
||
### Updating the list | ||
|
||
> You will need **gyb** installed on your machine. | ||
After updating the [`Resources/ISO4217.csv`](/Resources/ISO4217.csv) with the latest from the [ISO Currency Workgroup](https://www.currency-iso.org/en/home/tables/table-a1.html), | ||
run the following command: | ||
|
||
```bash | ||
find . -name '*.gyb' | \ | ||
while read file; do \ | ||
<path to gyb> --line-directive '' -o "${file%.gyb}" "$file"; \ | ||
done | ||
``` |
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,159 @@ | ||
CtryNm,CcyNm,Ccy,CcyNbr,CcyMnrUnts,CcyNm/_IsFund,CcyNm/__text | ||
UNITED ARAB EMIRATES (THE),UAE Dirham,AED,784,2,, | ||
AFGHANISTAN,Afghani,AFN,971,2,, | ||
ALBANIA,Lek,ALL,8,2,, | ||
ARMENIA,Armenian Dram,AMD,51,2,, | ||
CURAÇAO,Netherlands Antillean Guilder,ANG,532,2,, | ||
ANGOLA,Kwanza,AOA,973,2,, | ||
ARGENTINA,Argentine Peso,ARS,32,2,, | ||
AUSTRALIA,Australian Dollar,AUD,36,2,, | ||
ARUBA,Aruban Florin,AWG,533,2,, | ||
AZERBAIJAN,Azerbaijan Manat,AZN,944,2,, | ||
BOSNIA AND HERZEGOVINA,Convertible Mark,BAM,977,2,, | ||
BARBADOS,Barbados Dollar,BBD,52,2,, | ||
BANGLADESH,Taka,BDT,50,2,, | ||
BULGARIA,Bulgarian Lev,BGN,975,2,, | ||
BAHRAIN,Bahraini Dinar,BHD,48,3,, | ||
BURUNDI,Burundi Franc,BIF,108,0,, | ||
BERMUDA,Bermudian Dollar,BMD,60,2,, | ||
BRUNEI DARUSSALAM,Brunei Dollar,BND,96,2,, | ||
BOLIVIA (PLURINATIONAL STATE OF),Boliviano,BOB,68,2,, | ||
BRAZIL,Brazilian Real,BRL,986,2,, | ||
BAHAMAS (THE),Bahamian Dollar,BSD,44,2,, | ||
BHUTAN,Ngultrum,BTN,64,2,, | ||
BOTSWANA,Pula,BWP,72,2,, | ||
BELARUS,Belarusian Ruble,BYN,933,2,, | ||
BELIZE,Belize Dollar,BZD,84,2,, | ||
CANADA,Canadian Dollar,CAD,124,2,, | ||
CONGO (THE DEMOCRATIC REPUBLIC OF THE),Congolese Franc,CDF,976,2,, | ||
SWITZERLAND,Swiss Franc,CHF,756,2,, | ||
CHILE,Chilean Peso,CLP,152,0,, | ||
CHINA,Yuan Renminbi,CNY,156,2,, | ||
COLOMBIA,Colombian Peso,COP,170,2,, | ||
COSTA RICA,Costa Rican Colon,CRC,188,2,, | ||
CUBA,Peso Convertible,CUC,931,2,, | ||
CUBA,Cuban Peso,CUP,192,2,, | ||
CABO VERDE,Cabo Verde Escudo,CVE,132,2,, | ||
CZECHIA,Czech Koruna,CZK,203,2,, | ||
DJIBOUTI,Djibouti Franc,DJF,262,0,, | ||
DENMARK,Danish Krone,DKK,208,2,, | ||
DOMINICAN REPUBLIC (THE),Dominican Peso,DOP,214,2,, | ||
ALGERIA,Algerian Dinar,DZD,12,2,, | ||
EGYPT,Egyptian Pound,EGP,818,2,, | ||
ERITREA,Nakfa,ERN,232,2,, | ||
ETHIOPIA,Ethiopian Birr,ETB,230,2,, | ||
ÅLAND ISLANDS,Euro,EUR,978,2,, | ||
FIJI,Fiji Dollar,FJD,242,2,, | ||
FALKLAND ISLANDS (THE) [MALVINAS],Falkland Islands Pound,FKP,238,2,, | ||
UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND (THE),Pound Sterling,GBP,826,2,, | ||
GEORGIA,Lari,GEL,981,2,, | ||
GHANA,Ghana Cedi,GHS,936,2,, | ||
GIBRALTAR,Gibraltar Pound,GIP,292,2,, | ||
GAMBIA (THE),Dalasi,GMD,270,2,, | ||
GUINEA,Guinean Franc,GNF,324,0,, | ||
GUATEMALA,Quetzal,GTQ,320,2,, | ||
GUYANA,Guyana Dollar,GYD,328,2,, | ||
HONG KONG,Hong Kong Dollar,HKD,344,2,, | ||
HONDURAS,Lempira,HNL,340,2,, | ||
CROATIA,Kuna,HRK,191,2,, | ||
HAITI,Gourde,HTG,332,2,, | ||
HUNGARY,Forint,HUF,348,2,, | ||
INDONESIA,Rupiah,IDR,360,2,, | ||
ISRAEL,New Israeli Sheqel,ILS,376,2,, | ||
INDIA,Indian Rupee,INR,356,2,, | ||
IRAQ,Iraqi Dinar,IQD,368,3,, | ||
IRAN (ISLAMIC REPUBLIC OF),Iranian Rial,IRR,364,2,, | ||
ICELAND,Iceland Krona,ISK,352,0,, | ||
JAMAICA,Jamaican Dollar,JMD,388,2,, | ||
JORDAN,Jordanian Dinar,JOD,400,3,, | ||
JAPAN,Yen,JPY,392,0,, | ||
KENYA,Kenyan Shilling,KES,404,2,, | ||
KYRGYZSTAN,Som,KGS,417,2,, | ||
CAMBODIA,Riel,KHR,116,2,, | ||
COMOROS (THE),Comorian Franc,KMF,174,0,, | ||
KOREA (THE DEMOCRATIC PEOPLE’S REPUBLIC OF),North Korean Won,KPW,408,2,, | ||
KOREA (THE REPUBLIC OF),Won,KRW,410,0,, | ||
KUWAIT,Kuwaiti Dinar,KWD,414,3,, | ||
CAYMAN ISLANDS (THE),Cayman Islands Dollar,KYD,136,2,, | ||
KAZAKHSTAN,Tenge,KZT,398,2,, | ||
LAO PEOPLE’S DEMOCRATIC REPUBLIC (THE),Lao Kip,LAK,418,2,, | ||
LEBANON,Lebanese Pound,LBP,422,2,, | ||
SRI LANKA,Sri Lanka Rupee,LKR,144,2,, | ||
LIBERIA,Liberian Dollar,LRD,430,2,, | ||
LESOTHO,Loti,LSL,426,2,, | ||
LIBYA,Libyan Dinar,LYD,434,3,, | ||
MOROCCO,Moroccan Dirham,MAD,504,2,, | ||
MOLDOVA (THE REPUBLIC OF),Moldovan Leu,MDL,498,2,, | ||
MADAGASCAR,Malagasy Ariary,MGA,969,2,, | ||
MACEDONIA (THE FORMER YUGOSLAV REPUBLIC OF),Denar,MKD,807,2,, | ||
MYANMAR,Kyat,MMK,104,2,, | ||
MONGOLIA,Tugrik,MNT,496,2,, | ||
MACAO,Pataca,MOP,446,2,, | ||
MAURITANIA,Ouguiya,MRU,929,2,, | ||
MAURITIUS,Mauritius Rupee,MUR,480,2,, | ||
MALDIVES,Rufiyaa,MVR,462,2,, | ||
MALAWI,Malawi Kwacha,MWK,454,2,, | ||
MEXICO,Mexican Peso,MXN,484,2,, | ||
MALAYSIA,Malaysian Ringgit,MYR,458,2,, | ||
MOZAMBIQUE,Mozambique Metical,MZN,943,2,, | ||
NAMIBIA,Namibia Dollar,NAD,516,2,, | ||
NIGERIA,Naira,NGN,566,2,, | ||
NICARAGUA,Cordoba Oro,NIO,558,2,, | ||
NORWAY,Norwegian Krone,NOK,578,2,, | ||
NEPAL,Nepalese Rupee,NPR,524,2,, | ||
NEW ZEALAND,New Zealand Dollar,NZD,554,2,, | ||
OMAN,Rial Omani,OMR,512,3,, | ||
PANAMA,Balboa,PAB,590,2,, | ||
PERU,Sol,PEN,604,2,, | ||
PAPUA NEW GUINEA,Kina,PGK,598,2,, | ||
PHILIPPINES (THE),Philippine Peso,PHP,608,2,, | ||
PAKISTAN,Pakistan Rupee,PKR,586,2,, | ||
POLAND,Zloty,PLN,985,2,, | ||
PARAGUAY,Guarani,PYG,600,0,, | ||
QATAR,Qatari Rial,QAR,634,2,, | ||
ROMANIA,Romanian Leu,RON,946,2,, | ||
SERBIA,Serbian Dinar,RSD,941,2,, | ||
RUSSIAN FEDERATION (THE),Russian Ruble,RUB,643,2,, | ||
RWANDA,Rwanda Franc,RWF,646,0,, | ||
SAUDI ARABIA,Saudi Riyal,SAR,682,2,, | ||
SOLOMON ISLANDS,Solomon Islands Dollar,SBD,90,2,, | ||
SEYCHELLES,Seychelles Rupee,SCR,690,2,, | ||
SUDAN (THE),Sudanese Pound,SDG,938,2,, | ||
SWEDEN,Swedish Krona,SEK,752,2,, | ||
SINGAPORE,Singapore Dollar,SGD,702,2,, | ||
"SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA",Saint Helena Pound,SHP,654,2,, | ||
SIERRA LEONE,Leone,SLL,694,2,, | ||
SOMALIA,Somali Shilling,SOS,706,2,, | ||
SURINAME,Surinam Dollar,SRD,968,2,, | ||
SOUTH SUDAN,South Sudanese Pound,SSP,728,2,, | ||
SAO TOME AND PRINCIPE,Dobra,STN,930,2,, | ||
EL SALVADOR,El Salvador Colon,SVC,222,2,, | ||
SYRIAN ARAB REPUBLIC,Syrian Pound,SYP,760,2,, | ||
ESWATINI,Lilangeni,SZL,748,2,, | ||
THAILAND,Baht,THB,764,2,, | ||
TAJIKISTAN,Somoni,TJS,972,2,, | ||
TURKMENISTAN,Turkmenistan New Manat,TMT,934,2,, | ||
TUNISIA,Tunisian Dinar,TND,788,3,, | ||
TONGA,Pa’anga,TOP,776,2,, | ||
TURKEY,Turkish Lira,TRY,949,2,, | ||
TRINIDAD AND TOBAGO,Trinidad and Tobago Dollar,TTD,780,2,, | ||
TAIWAN (PROVINCE OF CHINA),New Taiwan Dollar,TWD,901,2,, | ||
"TANZANIA, UNITED REPUBLIC OF",Tanzanian Shilling,TZS,834,2,, | ||
UKRAINE,Hryvnia,UAH,980,2,, | ||
UGANDA,Uganda Shilling,UGX,800,0,, | ||
UNITED STATES OF AMERICA (THE),US Dollar,USD,840,2,, | ||
URUGUAY,Peso Uruguayo,UYU,858,2,, | ||
URUGUAY,Unidad Previsional,UYW,927,4,, | ||
UZBEKISTAN,Uzbekistan Sum,UZS,860,2,, | ||
VENEZUELA (BOLIVARIAN REPUBLIC OF),Bolívar Soberano,VES,928,2,, | ||
VIET NAM,Dong,VND,704,0,, | ||
VANUATU,Vatu,VUV,548,0,, | ||
SAMOA,Tala,WST,882,2,, | ||
CAMEROON,CFA Franc BEAC,XAF,950,0,, | ||
ANGUILLA,East Caribbean Dollar,XCD,951,2,, | ||
BENIN,CFA Franc BCEAO,XOF,952,0,, | ||
FRENCH POLYNESIA,CFP Franc,XPF,953,0,, | ||
YEMEN,Yemeni Rial,YER,886,2,, | ||
LESOTHO,Rand,ZAR,710,2,, | ||
ZAMBIA,Zambian Kwacha,ZMW,967,2,, | ||
ZIMBABWE,Zimbabwe Dollar,ZWL,932,2,, |
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 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Currency open source project | ||
// | ||
// Copyright (c) 2020 Currency project authors | ||
// Licensed under MIT License | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of Currency project authors | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// A type that provides static currency information as defined by ISO 4217. | ||
public protocol CurrencyMetadata { | ||
/// The name of the currency, such as "United States Dollar". | ||
static var name: String { get } | ||
/// The ISO 4217 3-digit letter currency code. | ||
/// | ||
/// For example: "USD" for "United States Dollar". | ||
static var alphabeticCode: String { get } | ||
/// The ISO 4217 3-digit numeric currency code. | ||
/// | ||
/// This code is nomally the same as the ISO 3166-1 country codes, where appropriate. | ||
/// | ||
/// For example, "United States of America" has the ISO 3166-1 code of 840, which is the same for the "USD" currency in ISO 4217. | ||
static var numericCode: UInt16 { get } | ||
/// The number of decimal digits used to express minor units of the currency. | ||
/// | ||
/// For example, the US Dollar has the minor unit (cents) that are 1/100 of a dollar. Therefore, the the minorUnits is `2`. | ||
/// | ||
/// However, the Japanese Yen has no minor unit, so it has `0` minorUnits. | ||
static var minorUnits: UInt8 { get } | ||
} |
Oops, something went wrong.