mirror of
https://github.com/ppy/osu
synced 2025-01-31 10:22:02 +00:00
Use TimeSpan to represent time.
This commit is contained in:
parent
d277952e0f
commit
c5aebf6401
@ -70,13 +70,11 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
|
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
|
||||||
|
|
||||||
private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - (startTime ?? 0)));
|
private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow - (startTime ?? DateTimeOffset.MinValue)).TotalMilliseconds);
|
||||||
|
|
||||||
public bool ExceededTimeout => remainingTime == 0;
|
public bool ExceededTimeout => remainingTime == 0;
|
||||||
|
|
||||||
private double? startTime;
|
private DateTimeOffset? startTime;
|
||||||
|
|
||||||
public double StartTime => startTime ?? -1;
|
|
||||||
|
|
||||||
protected APIAccess API;
|
protected APIAccess API;
|
||||||
protected WebRequest WebRequest;
|
protected WebRequest WebRequest;
|
||||||
@ -96,7 +94,7 @@ namespace osu.Game.Online.API
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (startTime == null)
|
if (startTime == null)
|
||||||
startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
startTime = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
if (remainingTime <= 0)
|
if (remainingTime <= 0)
|
||||||
throw new TimeoutException(@"API request timeout hit");
|
throw new TimeoutException(@"API request timeout hit");
|
||||||
|
Loading…
Reference in New Issue
Block a user