fix formatting of credits

This commit is contained in:
Florian Stinglmayr 2021-08-27 22:37:06 +02:00
parent ec872e4aec
commit f94b4084c9

View File

@ -3,18 +3,19 @@
namespace EDJournal { namespace EDJournal {
public class Credits { public class Credits {
public static string FormatCredits(int amount) { public static string FormatCredits(int amount) {
var format = CultureInfo.CurrentCulture.NumberFormat; var format = new CultureInfo(CultureInfo.CurrentCulture.Name, true).NumberFormat;
format.NumberGroupSeparator = ","; format.NumberGroupSeparator = ",";
format.NumberGroupSizes = new int[1] { 3 }; format.NumberGroupSizes = new int[1] { 3 };
format.NumberDecimalDigits = 0;
if ((amount % 1000000) == 0) { if ((amount % 1000000) == 0) {
amount /= 1000000; amount /= 1000000;
return string.Format("{0}M CR", amount.ToString(format)); return string.Format("{0}M CR", amount.ToString("N", format));
} else if ((amount % 1000) == 0) { } else if ((amount % 1000) == 0) {
amount /= 1000; amount /= 1000;
return string.Format("{0}K CR", amount.ToString(format)); return string.Format("{0}K CR", amount.ToString("N", format));
} }
return string.Format("{0} CR", amount.ToString(format)); return string.Format("{0} CR", amount.ToString("N", format));
} }
} }
} }