LEFT | RIGHT |
1 /* | 1 /* |
2 Copyright 2013 Google Inc | 2 Copyright 2013 Google Inc |
3 | 3 |
4 Licensed under the Apache License, Version 2.0 (the "License"); | 4 Licensed under the Apache License, Version 2.0 (the "License"); |
5 you may not use this file except in compliance with the License. | 5 you may not use this file except in compliance with the License. |
6 You may obtain a copy of the License at | 6 You may obtain a copy of the License at |
7 | 7 |
8 http://www.apache.org/licenses/LICENSE-2.0 | 8 http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 |
10 Unless required by applicable law or agreed to in writing, software | 10 Unless required by applicable law or agreed to in writing, software |
11 distributed under the License is distributed on an "AS IS" BASIS, | 11 distributed under the License is distributed on an "AS IS" BASIS, |
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 See the License for the specific language governing permissions and | 13 See the License for the specific language governing permissions and |
14 limitations under the License. | 14 limitations under the License. |
15 */ | 15 */ |
16 | 16 |
17 using System; | 17 using System; |
18 | 18 |
19 namespace Google.Apis.Util | 19 namespace Google.Apis.Util |
20 { | 20 { |
21 /// <summary>Clock wrapper for getting the current time.</summary> | 21 /// <summary>Clock wrapper for getting the current time.</summary> |
22 public interface IClock | 22 public interface IClock |
23 { | 23 { |
24 /// <summary> | 24 /// <summary> |
25 /// Gets a <seealso cref="DateTime"/> object that is set to the current
date and time on this computer,· | 25 /// Gets a <seealso cref="DateTime"/> object that is set to the current
date and time on this computer,· |
26 /// expressed as the local time. | 26 /// expressed as the local time. |
27 /// </summary> | 27 /// </summary> |
28 DateTime Now { get; } | 28 DateTime Now { get; } |
| 29 |
| 30 /// <summary> |
| 31 /// Gets a <seealso cref="DateTime"/> object that is set to the current
date and time on this computer,· |
| 32 /// expressed as UTC time. |
| 33 /// </summary> |
| 34 DateTime UtcNow { get; } |
29 } | 35 } |
30 | 36 |
31 /// <summary>A default clock implementation that wraps the <seealso cref="Da
teTime.Now"/> property.</summary> | 37 /// <summary>A default clock implementation that wraps the <seealso cref="Da
teTime.Now"/> property.</summary> |
32 public class SystemClock : IClock | 38 public class SystemClock : IClock |
33 { | 39 { |
34 /// <summary>Constructs a new system clock.</summary> | 40 /// <summary>Constructs a new system clock.</summary> |
35 protected SystemClock() { } | 41 protected SystemClock() { } |
36 | 42 |
37 /// <summary>The default instance.</summary> | 43 /// <summary>The default instance.</summary> |
38 public static readonly IClock Default = new SystemClock(); | 44 public static readonly IClock Default = new SystemClock(); |
39 | 45 |
40 public DateTime Now | 46 public DateTime Now |
41 { | 47 { |
| 48 get { return DateTime.Now; } |
| 49 } |
| 50 |
| 51 public DateTime UtcNow |
| 52 { |
42 get { return DateTime.UtcNow; } | 53 get { return DateTime.UtcNow; } |
43 } | 54 } |
44 } | 55 } |
45 } | 56 } |
LEFT | RIGHT |