Skip to content

Commit

Permalink
[DB] Force InvariantCulture when converting to double
Browse files Browse the repository at this point in the history
  • Loading branch information
gablm committed Oct 13, 2024
1 parent d3df330 commit ae8f379
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void AddMinute()
playtimeInner._gameVersion = _gameVersion;
DbConfig.SetAndSaveValue(KeyLastUpdated, _unixStampDb.ToString());
LastDbUpdate = DateTime.Now;
Save();
playtimeInner.Save();
return (true, playtimeInner);
}

Expand Down Expand Up @@ -351,11 +351,11 @@ private async Task UpdatePlaytime_Database_Push(string jsonData, double totalTim
var unixStamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
await DbHandler.StoreKeyValue(KeyPlaytimeJson, jsonData);
await DbHandler.StoreKeyValue(KeyTotalTime, totalTime.ToString(CultureInfo.InvariantCulture));
await DbHandler.StoreKeyValue(KeyLastPlayed, lastPlayed != null ? lastPlayed.ToString() : "null");
await DbHandler.StoreKeyValue(KeyLastPlayed, lastPlayed != null ? lastPlayed.Value.ToString(CultureInfo.InvariantCulture) : "null");
await DbHandler.StoreKeyValue(KeyLastUpdated, unixStamp.ToString());
DbConfig.SetAndSaveValue(KeyLastUpdated, unixStamp);
_unixStampDb = Convert.ToInt32(unixStamp);
LastDbUpdate = curDateTime;
_unixStampDb = Convert.ToInt32(unixStamp);
LastDbUpdate = curDateTime;
}
catch (Exception e)
{
Expand All @@ -378,10 +378,10 @@ private async Task UpdatePlaytime_Database_Pull()
_jsonDataDb = await DbHandler.QueryKey(KeyPlaytimeJson);

var totalTimeDbStr = await DbHandler.QueryKey(KeyTotalTime);
_totalTimeDb = string.IsNullOrEmpty(totalTimeDbStr) ? null : Convert.ToDouble(totalTimeDbStr);
_totalTimeDb = string.IsNullOrEmpty(totalTimeDbStr) ? null : Convert.ToDouble(totalTimeDbStr, CultureInfo.InvariantCulture);

var lpDb = await DbHandler.QueryKey(KeyLastPlayed);
_lastPlayedDb = !string.IsNullOrEmpty(lpDb) && !lpDb.Contains("null") ? Convert.ToDouble(lpDb) : null; // if Db data is null, return null
_lastPlayedDb = !string.IsNullOrEmpty(lpDb) && !lpDb.Contains("null") ? Convert.ToDouble(lpDb, CultureInfo.InvariantCulture) : null; // if Db data is null, return null

_isDbPullSuccess = true;
}
Expand Down
4 changes: 2 additions & 2 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- ReSharper disable IdentifierTypo -->
<!-- ReSharper disable IdentifierTypo -->
<!-- ReSharper disable UnusedMember.Local -->
<!-- ReSharper disable Xaml.ConstructorWarning -->
<Page x:Class="CollapseLauncher.Pages.HomePage"
Expand Down Expand Up @@ -2428,7 +2428,7 @@
</Grid>
</Button>
<Button x:Name="ResetPlaytimeButton"
Margin="-4,0,-4,-4"
Margin="-4,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left"
Click="ResetPlaytimeButton_Click"
Expand Down

0 comments on commit ae8f379

Please sign in to comment.