fixed some conversion bug

This commit is contained in:
Gergő Törcsvári 2016-04-26 23:17:40 +02:00
parent 42261a01b5
commit de3e8f80ff

View File

@ -92,6 +92,8 @@ namespace NadekoBot.Modules.Searches.Commands
}
else
{
CultureInfo ci = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = ci;
reInitCurrencyConverterTable();
Unit inUnit = currTable.CreateUnit(quantity, from.ToUpperInvariant());
Unit outUnit = inUnit.Convert(currTable.CurrencyCode(to.ToUpperInvariant()));
@ -108,11 +110,18 @@ namespace NadekoBot.Modules.Searches.Commands
private void reInitCurrencyConverterTable()
{
if (lastChanged == null || lastChanged.DayOfYear != DateTime.Now.DayOfYear)
{
try
{
exchangeRateProvider = new WebExchangeRatesProvider();
currTable = new CurrencyExchangeTable(exchangeRateProvider);
lastChanged = DateTime.Now;
}
catch
{
Console.WriteLine("Error with the currency download.");
}
}
}
private void ResolveUnitCodes(string from, string to, out UnitTable table, out int fromCode, out int toCode)