mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:42:56 +08:00
Use DateTimeOffset.ToUnixTime
This commit is contained in:
parent
b59379252b
commit
d277952e0f
@ -70,7 +70,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
|
||||
|
||||
private double remainingTime => Math.Max(0, Timeout - (DateTime.Now.TotalMilliseconds() - (startTime ?? 0)));
|
||||
private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - (startTime ?? 0)));
|
||||
|
||||
public bool ExceededTimeout => remainingTime == 0;
|
||||
|
||||
@ -96,7 +96,7 @@ namespace osu.Game.Online.API
|
||||
return;
|
||||
|
||||
if (startTime == null)
|
||||
startTime = DateTime.Now.TotalMilliseconds();
|
||||
startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
|
||||
if (remainingTime <= 0)
|
||||
throw new TimeoutException(@"API request timeout hit");
|
||||
|
@ -22,12 +22,12 @@ namespace osu.Game.Online.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return AccessTokenExpiry - DateTime.Now.ToUnixTimestamp();
|
||||
return AccessTokenExpiry - DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
AccessTokenExpiry = DateTime.Now.AddSeconds(value).ToUnixTimestamp();
|
||||
AccessTokenExpiry = DateTimeOffset.Now.AddSeconds(value).ToUnixTimeSeconds();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user