-
Notifications
You must be signed in to change notification settings - Fork 1
/
High Precision Time Stamps.csproj
147 lines (125 loc) · 8.95 KB
/
High Precision Time Stamps.csproj
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>HpTimeStamps</RootNamespace>
<AssemblyName>HighPrecisionTimeStamps</AssemblyName>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Authors>Christopher P. Susie</Authors>
<Company>CJM Screws, LLC</Company>
<Version>1.0.0.7-beta</Version>
<Description>It is well known that DateTime.Now is often used inappropriately. For example, it may be used together with TimeSpan to produce a task's timeout point or subtracted from another DateTime to calculate a duration. This can cause subtle bugs because DateTime is not monotonic: the system clock can change, making the result of the subtraction inaccurate -- potentially causing a premature timeout or an infinite loop. Yet, DateTime is an incredibly convenient and widely used value type in .NET code and is especially useful when printed in ISO-8601 format (with the "O" format specifier).
With the "O" specifier, you can resolution down to tenths of a microsecond, which is nice. Until you learn that the resolution of the system clock is usually more coarse than several *milliseconds*, making the additional decimal places misleading garbage values. For calculating durations (time between events), it is better to use a high-resolution and monotonic clock like that provided by System.Diagnostics.Stopwatch: on most computers it is far more **accurate** than DateTime.Now even though, seemingly paradoxically, on a few systems, its *resolution* is lower than that of DateTime. Also, unsurprisingly, Stopwatch does not provide values that correlate to times of day: while it is appropriate for calculating durations, it is inappropriate for timestamping against a readable date and time.
This library provides timestamps (both as DateTime and as analogous value types it defines) that use the Stopwatch (and your system's high peformance event counter) as its clock, but returns values as DateTimes or an analog thereto so that these values can be used for a mixed purpose of timestamping and providing a meaningful way to calculate time elapsed between events or to calculate how long to perform a programmatic task.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>
#### Version 1.0.0.6:
To resolve ([Issue 24][10]), add Parse and TryParse methods to parse stringified PortableMonotonicTimestamps and PortableDurations. These methods only work with values stringified via the default ToString() methods.
Added unit tests for the methods.
Unit test application now enables the nullable reference type feature.
#### Version 1.0.0.4:
This release fixes two bugs.
First (see [Issue 21][8]), it fixes a bug where using monotonic timestamps close to the extreme values (within a month or so of 1-1-0001AD and 12-31-9999AD) was causing overflow in .NET 5.0. The fix increased the buffer around the min/max values so that overflow does not occur in .NET 5.0. You may have to alter your uses if you were (for some reason) storing portable monotonic stamps close to the extrema of permissible values.
Second (see [Issue 22][9]), it fixes a bug where subtracting a portable duration from a portable monotonic stamp was executing addition, not subtraction.
Finally, please note that unit test applications, example code and test application are now all built and run against .NET 5.0 rather than .NET Core 3.1.
#### Version 1.0.0.2:
This release fixes a bug (see [Issue 19][1]) where the PortableDuration type's FromDays factory methods (and perhaps other From factory methods taking a double as a parameter) used incorrect math and incorrect validation logic.
#### Version 1.0.0.1:
This release contains no changes to the code itself or to program behavior. Instead it merely fixes the repository url to refer to the source repository rather than the http page that hosts the Github repository. Also, it enables the nuget package to be built deterministically.
#### Version 1.0.0.0:
This is the non-beta release of the fix introduced with beta version 0.1.1.0-beta. The issues resolved by that release included problems with serialization and deserialization of portable monotonic stamps when serialized on a system with a different DateTime.MinValue.ToUniversalTime() value than the one on which it is deserialized. Those changes are discussed in [pull request 14][2], [issue 12][3] and [issue 13][4]. The changes to the code can be reviewed in [pull request 14][2], [commit x][6] and, most particularly around [these lines of code][7].
[1]: https://github.com/cpsusie/High-Precision-Time-Stamps/issues/19
[2]: https://github.com/cpsusie/High-Precision-Time-Stamps/pull/14
[3]: https://github.com/cpsusie/High-Precision-Time-Stamps/issues/12
[4]: https://github.com/cpsusie/High-Precision-Time-Stamps/issues/13
[5]: https://github.com/cpsusie/High-Precision-Time-Stamps/pull/14
[6]: https://github.com/cpsusie/High-Precision-Time-Stamps/commit/01670d88755a4775100f7dd9d09eef61e0775555
[7]: https://github.com/cpsusie/High-Precision-Time-Stamps/blob/01670d88755a4775100f7dd9d09eef61e0775555/PortableMonotonicStamp.cs#L540
[8]: https://github.com/cpsusie/High-Precision-Time-Stamps/issues/21
[9]: https://github.com/cpsusie/High-Precision-Time-Stamps/issues/22
[10]: https://github.com/cpsusie/High-Precision-Time-Stamps/issues/24
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/cpsusie/High-Precision-Time-Stamps.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Timestamps DateTime Duration Monotonic-Clock TimeSpan High-Resolution ISO-8601</PackageTags>
<AssemblyVersion>1.0.0.7</AssemblyVersion>
<FileVersion>1.0.0.7</FileVersion>
<Copyright>Copyright (c) 2020-2022 CJM Screws, LLC</Copyright>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageProjectUrl>https://github.com/cpsusie/High-Precision-Time-Stamps</PackageProjectUrl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>./HighPrecisionTimeStamps.xml</DocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsAsErrors />
<LangVersion>9</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<DocumentationFile>./HighPrecisionTimeStamps.xml</DocumentationFile>
<LangVersion>9</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Remove="ExampleCode\**" />
<Compile Remove="Int128_Test_Helper\**" />
<Compile Remove="TestApp\**" />
<Compile Remove="UnitTests\**" />
<EmbeddedResource Remove="ExampleCode\**" />
<EmbeddedResource Remove="Int128_Test_Helper\**" />
<EmbeddedResource Remove="TestApp\**" />
<EmbeddedResource Remove="UnitTests\**" />
<None Remove="ExampleCode\**" />
<None Remove="Int128_Test_Helper\**" />
<None Remove="TestApp\**" />
<None Remove="UnitTests\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="BigMath\BigInteger.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="LICENSE" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.2.0" />
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<None Update="BigMath\BIGMATH_LICENSE.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>docs</PackagePath>
<Visible>False</Visible>
</None>
<None Update="BigMath\BIG_MATH_README.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>docs</PackagePath>
<Visible>False</Visible>
</None>
<None Update="BigMath\License_NOTES_CJM.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>docs</PackagePath>
<Visible>False</Visible>
</None>
<None Update="Release.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>docs</PackagePath>
<Visible>False</Visible>
</None>
<None Update="LICENSE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>True</Pack>
<Visible>False</Visible>
<PackagePath>docs</PackagePath>
</None>
</ItemGroup>
</Project>