Truncate SystemClock to Seconds Precision (#1110)
This commit is contained in:
parent
7dd6ee791a
commit
fea5d5cfdc
|
|
@ -7,7 +7,7 @@ using System;
|
|||
namespace Microsoft.AspNetCore.Authentication
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to the normal system clock.
|
||||
/// Provides access to the normal system clock with precision in seconds.
|
||||
/// </summary>
|
||||
public class SystemClock : ISystemClock
|
||||
{
|
||||
|
|
@ -20,8 +20,8 @@ namespace Microsoft.AspNetCore.Authentication
|
|||
{
|
||||
// the clock measures whole seconds only, to have integral expires_in results, and
|
||||
// because milliseconds do not round-trip serialization formats
|
||||
DateTimeOffset utcNow = DateTimeOffset.UtcNow;
|
||||
return utcNow.AddMilliseconds(-utcNow.Millisecond);
|
||||
var utcNowPrecisionSeconds = new DateTime((DateTime.UtcNow.Ticks / TimeSpan.TicksPerSecond) * TimeSpan.TicksPerSecond, DateTimeKind.Utc);
|
||||
return new DateTimeOffset(utcNowPrecisionSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue