File tree 3 files changed +23
-1
lines changed
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 10
10
<PackageReleaseNotes >https://github.com/hbjorgo/TimeService/releases</PackageReleaseNotes >
11
11
<PackageTags >time timeservice time-service timefunc time-func</PackageTags >
12
12
<RepositoryUrl >https://github.com/hbjorgo/TimeService</RepositoryUrl >
13
- <Version >1.0.1 </Version >
13
+ <Version >1.1.0 </Version >
14
14
</PropertyGroup >
15
15
16
16
</Project >
Original file line number Diff line number Diff line change @@ -4,7 +4,14 @@ namespace HeboTech.TimeService
4
4
{
5
5
public class TimeProviders
6
6
{
7
+ /// <summary>
8
+ /// Returns DateTime.Now
9
+ /// </summary>
7
10
public static Func < DateTime > SystemTime => ( ) => DateTime . Now ;
11
+
12
+ /// <summary>
13
+ /// Returns DateTime.UtcNow
14
+ /// </summary>
8
15
public static Func < DateTime > SystemTimeUtc => ( ) => DateTime . UtcNow ;
9
16
}
10
17
}
Original file line number Diff line number Diff line change @@ -5,9 +5,24 @@ namespace HeboTech.TimeService
5
5
public static class TimeService
6
6
{
7
7
private static Func < DateTime > timeFunc ;
8
+
9
+ /// <summary>
10
+ /// Gets a DateTime object that represents the current time
11
+ /// </summary>
8
12
public static DateTime Now => timeFunc ( ) ;
9
13
14
+ /// <summary>
15
+ /// Sets the current time. The func can either return a constant time, or a dynamic one (like DateTime.Now).
16
+ /// </summary>
17
+ /// <param name="timeFunc">Func that returns the current time</param>
10
18
public static void Set ( Func < DateTime > timeFunc ) =>
11
19
TimeService . timeFunc = timeFunc ?? throw new ArgumentNullException ( nameof ( timeFunc ) ) ;
20
+
21
+ /// <summary>
22
+ /// Sets the current (constant) time.
23
+ /// </summary>
24
+ /// <param name="now">The current (constant) time</param>
25
+ public static void SetConstant ( DateTime now ) =>
26
+ timeFunc = ( ) => now ;
12
27
}
13
28
}
You can’t perform that action at this time.
0 commit comments