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
|
namespace Microsoft.AspNetCore.Authentication
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides access to the normal system clock.
|
/// Provides access to the normal system clock with precision in seconds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SystemClock : ISystemClock
|
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
|
// the clock measures whole seconds only, to have integral expires_in results, and
|
||||||
// because milliseconds do not round-trip serialization formats
|
// because milliseconds do not round-trip serialization formats
|
||||||
DateTimeOffset utcNow = DateTimeOffset.UtcNow;
|
var utcNowPrecisionSeconds = new DateTime((DateTime.UtcNow.Ticks / TimeSpan.TicksPerSecond) * TimeSpan.TicksPerSecond, DateTimeKind.Utc);
|
||||||
return utcNow.AddMilliseconds(-utcNow.Millisecond);
|
return new DateTimeOffset(utcNowPrecisionSeconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue