Formats for more currencies, and make that format function public

This commit is contained in:
Rohan Singh 2018-12-02 13:57:09 -05:00
parent 6c6c8dc696
commit e69e25a1f1

View File

@ -60,22 +60,55 @@ public static uint FromDateTime( DateTime dt )
}
internal static string FormatPrice(string currency, ulong price)
public static string FormatPrice(string currency, ulong price)
{
var decimaled = (price / 100.0).ToString("0.00");
switch (currency )
switch (currency)
{
case "GBP": return $"£{decimaled}";
case "USD": return $"${decimaled}";
case "AED": return $"{decimaled}د.إ";
case "ARS": return $"${decimaled} ARS";
case "AUD": return $"${decimaled} AUD";
case "BRL": return $"R$ {decimaled}";
case "CAD": return $"${decimaled} CAD";
case "CHF": return $"Fr. {decimaled}";
case "CLP": return $"${decimaled} CLP";
case "CNY": return $"{decimaled}元";
case "COP": return $"COL$ {decimaled}";
case "CRC": return $"₡{decimaled}";
case "EUR": return $"€{decimaled}";
case "RUB": return $"₽{decimaled}";
case "GBP": return $"£{decimaled}";
case "HKD": return $"HK$ {decimaled}";
case "ILS": return $"₪{decimaled}";
case "IDR": return $"Rp{decimaled}";
case "INR": return $"₹{decimaled}";
case "JPY": return $"¥{decimaled}";
case "KRW": return $"₩{decimaled}";
case "KWD": return $"KD {decimaled}";
case "KZT": return $"{decimaled}₸";
case "MXN": return $"Mex$ {decimaled}";
case "MYR": return $"RM {decimaled}";
case "NOK": return $"{decimaled} kr";
case "NZD": return $"${decimaled} NZD";
case "PEN": return $"S/. {decimaled}";
case "PHP": return $"₱{decimaled}";
case "PLN": return $"zł {decimaled}";
case "QAR": return $"QR {decimaled}";
case "RUB": return $"₽{decimaled}";
case "SAR": return $"SR {decimaled}";
case "SGD": return $"S$ {decimaled}";
case "THB": return $"฿{decimaled}";
case "TRY": return $"₺{decimaled}";
case "TWD": return $"NT$ {decimaled}";
case "UAH": return $"₴{decimaled}";
case "USD": return $"${decimaled}";
case "UYU": return $"$U {decimaled}"; // yes the U goes after $
case "VND": return $"₫{decimaled}";
case "ZAR": return $"R {decimaled}";
// TODO - all of them
// TODO - check all of them https://partner.steamgames.com/doc/store/pricing/currencies
default: return $"{decimaled}{currency}";
default: return $"{decimaled} {currency}";
}
}