Divis.DarkCalVer 23.54.5608

dotnet add package Divis.DarkCalVer --version 23.54.5608
NuGet\Install-Package Divis.DarkCalVer -Version 23.54.5608
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Divis.DarkCalVer" Version="23.54.5608" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Divis.DarkCalVer --version 23.54.5608
#r "nuget: Divis.DarkCalVer, 23.54.5608"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 using Accuracy.Hours).
  • Version (System.Version): same as VersionString, but parsed as a System.Version.
  • VersionNumber (long): total number of hours since the reference date (when using Accuracy.Hours).

Nuget

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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 168 4/6/2023