Divis.DarkCalVer
23.54.5608
dotnet add package Divis.DarkCalVer --version 23.54.5608
NuGet\Install-Package Divis.DarkCalVer -Version 23.54.5608
<PackageReference Include="Divis.DarkCalVer" Version="23.54.5608" />
paket add Divis.DarkCalVer --version 23.54.5608
#r "nuget: Divis.DarkCalVer, 23.54.5608"
// Install Divis.DarkCalVer as a Cake Addin #addin nuget:?package=Divis.DarkCalVer&version=23.54.5608 // Install Divis.DarkCalVer as a Cake Tool #tool nuget:?package=Divis.DarkCalVer&version=23.54.5608
<img src="assets/icon.png?raw=true" width="200">
Dark CalVer
C# simple implementation of the CalVer versioning scheme.
The version is calculated based on a timestamp, reference date and accuracy.
The CalVer
type contained in this library has the following properties:
- VersionString (
string
):yy.MM.ddhh
format (when usingAccuracy.Hours
). - Version (
System.Version
): same as VersionString, but parsed as aSystem.Version
. - VersionNumber (
long
): total number of hours since the reference date (when usingAccuracy.Hours
).
Nuget
DarkCalVer is available using nuget. To install DarkCalVer, run the following command in the Package Manager Console
PM> Install-Package Divis.DarkCalVer
Usage
Basic usage
using DarkCalVer;
var timestamp = new DateTime(2023, 1, 1, 08, 15, 30);
var calVer = CalVer.Create(timestamp);
// Version string: 23.01.0108
// Version: 23.1.108
// Version number: 26�312
Preventing leading zeros
Will prevent leading zeros by adding 50 to the minor and revision components of the version.
using DarkCalVer;
var timestamp = new DateTime(2023, 1, 1, 08, 15, 30);
var calVer = CalVer.Create(new CalVerOptions
{
Timestamp = timestamp,
PreventLeadingZeros = true,
});
// Version string: 23.51.5108
// Version: 23.51.5108
// Version number: 26�312
Custom reference date
A reference date is used to calculate the version number. When using Accuracy.Hours
, the version number is the total number of hours since the reference date. This number can become very large, especially when using Accuracy.Minutes
or Accuracy.Seconds
. To mitigate this, you can use a custom reference date that's as far in the future as your use case allows.
using DarkCalVer;
var timestamp = new DateTime(2023, 1, 1, 08, 15, 30);
var calVer = CalVer.Create(new CalVerOptions
{
Timestamp = timestamp,
ReferenceDate = new DateTime(2023, 1, 1),
});
// Version string: 23.01.0108
// Version: 23.1.108
// Version number: 8
Accuracy
The generated version will be unique per a given unit of accuracy. For example, if you use Accuracy.Hours
, the version will be unique per hour, and so on.
using DarkCalVer;
var timestamp = new DateTime(2023, 1, 1, 08, 15, 30);
var calVer = CalVer.Create(new CalVerOptions
{
Timestamp = timestamp,
Accuracy = Accuracy.Minutes
});
// Version string: 23.01.010815
// Version: 23.1.10815
// Version number: 1�578�735
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
23.54.5608 | 205 | 4/6/2023 |