Rewrite Steam time to ulongs (#2594)

My latest "research" resulted in learning that under the hood, Steam unix time seconds is bullet-proof not only for year 2038 but for uint range as well. While I do not expect to be alive by 2106, let alone ASF still being operative, it makes sense to base our time on the correct backend implementation regardless.

Small breaking change for people using `GetUnixTime()`.
This commit is contained in:
Łukasz Domeradzki
2022-06-01 21:13:50 +02:00
committed by GitHub
parent 715ed034df
commit 7fe5989f5d
3 changed files with 31 additions and 19 deletions

View File

@@ -94,7 +94,7 @@ public static class Utilities {
}
[PublicAPI]
public static uint GetUnixTime() => (uint) DateTimeOffset.UtcNow.ToUnixTimeSeconds();
public static ulong GetUnixTime() => (ulong) DateTimeOffset.UtcNow.ToUnixTimeSeconds();
[PublicAPI]
public static async void InBackground(Action action, bool longRunning = false) {
@@ -253,6 +253,16 @@ public static class Utilities {
}
}
internal static ulong MathAdd(ulong first, int second) {
if (second >= 0) {
first += (uint) second;
} else {
first -= (uint) -second;
}
return first;
}
internal static bool RelativeDirectoryStartsWith(string directory, params string[] prefixes) {
if (string.IsNullOrEmpty(directory)) {
throw new ArgumentNullException(nameof(directory));