Skip to content

Commit f7738fd

Browse files
committed
feat: Added TimeProvider.GetElapsedTime(long startingTimestamp)
1 parent 7a827b8 commit f7738fd

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.8.0]
11+
12+
- Added `TimeProvider.GetElapsedTime(long startingTimestamp)`
13+
1014
## [0.7.0]
1115

1216
- Add support for libraries that target netstandard 2.0.

src/TimeScheduler/System/TimeProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ public TimeSpan GetElapsedTime(long startingTimestamp, long endingTimestamp)
104104
return new TimeSpan((long)((endingTimestamp - startingTimestamp) * ((double)TimeSpan.TicksPerSecond / timestampFrequency)));
105105
}
106106

107+
/// <summary>
108+
/// Gets the elapsed time since the <paramref name="startingTimestamp"/> value retrieved using <see cref="GetTimestamp"/>.
109+
/// </summary>
110+
/// <param name="startingTimestamp">The timestamp marking the beginning of the time period.</param>
111+
/// <returns>A <see cref="TimeSpan"/> for the elapsed time between the starting timestamp and the time of this call./></returns>
112+
public TimeSpan GetElapsedTime(long startingTimestamp) => GetElapsedTime(startingTimestamp, GetTimestamp());
113+
107114
/// <summary>Creates a new <see cref="ITimer"/> instance, using <see cref="TimeSpan"/> values to measure time intervals.</summary>
108115
/// <param name="callback">
109116
/// A delegate representing a method to be executed when the timer fires. The method specified for callback should be reentrant,

src/TimeScheduler/TimeScheduler.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
55
<Title>Scheduler</Title>
6-
<Version>0.7.2</Version>
6+
<Version>0.8.0</Version>
77
<Company>Egil Hansen</Company>
88
<Authors>Egil Hansen</Authors>
99
<Description>

0 commit comments

Comments
 (0)