// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; namespace Microsoft.AspNetCore.Authentication { /// /// Provides access to the normal system clock with precision in seconds. /// public class SystemClock : ISystemClock { /// /// Retrieves the current system time in UTC. /// public DateTimeOffset UtcNow { get { // the clock measures whole seconds only, to have integral expires_in results, and // because milliseconds do not round-trip serialization formats var utcNowPrecisionSeconds = new DateTime((DateTime.UtcNow.Ticks / TimeSpan.TicksPerSecond) * TimeSpan.TicksPerSecond, DateTimeKind.Utc); return new DateTimeOffset(utcNowPrecisionSeconds); } } } }