-
Notifications
You must be signed in to change notification settings - Fork 51
/
SystemClock.cs
33 lines (29 loc) · 996 Bytes
/
SystemClock.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Copyright 2015 Google Inc. All Rights Reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file or at
* https://developers.google.com/open-source/licenses/bsd
*/
using System;
namespace Google.Api.Gax
{
/// <summary>
/// A singleton implementation of <see cref="IClock"/> which delegates to the BCL
/// <see cref="DateTime.UtcNow"/> property.
/// </summary>
public sealed class SystemClock : IClock
{
/// <summary>
/// Retrieves the singleton instance of this type.
/// </summary>
public static IClock Instance { get; } = new SystemClock();
private SystemClock()
{
}
/// <summary>
/// Returns the current date and time in UTC, using <see cref="DateTime.UtcNow"/>.
/// </summary>
/// <returns>The current date and time in UTC.</returns>
public DateTime GetCurrentDateTimeUtc() => DateTime.UtcNow;
}
}