From 916d9afdc915a39bfdae8c5e716c5621c9f672a6 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 31 Jan 2018 12:50:25 +0000 Subject: [PATCH] Added FormatPrice utility function --- Facepunch.Steamworks/Utility.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Facepunch.Steamworks/Utility.cs b/Facepunch.Steamworks/Utility.cs index c97c51c..7b048cc 100644 --- a/Facepunch.Steamworks/Utility.cs +++ b/Facepunch.Steamworks/Utility.cs @@ -59,5 +59,26 @@ public static uint FromDateTime( DateTime dt ) } } + + internal static string FormatPrice(string currency, ulong price) + { + var decimaled = (price / 100.0).ToString("0.00"); + + switch (currency ) + { + case "GBP": return $"£{decimaled}"; + case "USD": return $"${decimaled}"; + case "CAD": return $"${decimaled} CAD"; + case "EUR": return $"€{decimaled}"; + case "RUB": return $"₽{decimaled}"; + case "NZD": return $"${decimaled} NZD"; + + // TODO - all of them + + default: return $"{decimaled}{currency}"; + } + + + } } }