-
Notifications
You must be signed in to change notification settings - Fork 1
/
ITimeStampUtil.cs
64 lines (60 loc) · 2.52 KB
/
ITimeStampUtil.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
namespace HpTimeStamps
{
/// <summary>
/// Note that the times retrieved are not more accurate in ABSOLUTE terms.
/// If <see cref="IsHighPrecision"/> successive calls to get timestamp will
/// be more accurate (with respect to each other, within the <see cref="CalibrationWindow"/>).
/// </summary>
public interface ITimeStampUtil
{
/// <summary>
/// Number of ticks per second by the stop watch's (and if <see cref="IsHighPrecision"/>, the HPET's)
/// reckoning
/// </summary>
long StopWatchTicksPerSecond { get; }
/// <summary>
/// Number of ticks per second by DateTime and TimeSpan's reckoning
/// </summary>
long DateTimeTicksPerSecond { get; }
/// <summary>
/// Check whether high precision timestamps are possible, if not,
/// might as well use DateTime.Now (unless you want hp wherever possible)
/// </summary>
bool IsHighPrecision { get; }
/// <summary>
/// Like DateTime.Now but based off of a reading from the high precision event timer
/// and then converted into terms of the local time system
/// </summary>
DateTime CurrentLocalTimeStamp { get; }
/// <summary>
/// Like DateTime.UtcNow, but based off of a reading from the high precision event timer
/// then converted into terms of utc time system
/// </summary>
DateTime CurrentUtcTimeStamp { get; }
/// <summary>
/// The amount of time calibration lasts for.
/// </summary>
TimeSpan CalibrationWindow { get; }
/// <summary>
/// Amount of time since last calibration.
/// </summary>
TimeSpan TimeSinceLastCalibration { get; }
/// <summary>
/// Whether the util is calibrated at present
/// </summary>
bool IsCalibrated { get; }
/// <summary>
/// The offset from utc. To get utc time from local, SUBTRACT this value from local.
/// To get local from utc, add this value to utc.
/// </summary>
TimeSpan LocalOffsetFromUtc { get; }
/// <summary>
/// Manually force a calibration. If not calibrated, upon call to
/// <see cref="CurrentLocalTimeStamp"/> or <see cref="CurrentUtcTimeStamp"/> calibration will
/// be performed before TimeStamp retrieval causing a delay. If you want to avoid that,
/// calling this will do the trick.
/// </summary>
void Calibrate();
}
}