Ranges.Date
1.0.0
dotnet add package Ranges.Date --version 1.0.0
NuGet\Install-Package Ranges.Date -Version 1.0.0
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="Ranges.Date" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ranges.Date --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Ranges.Date, 1.0.0"
#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 Ranges.Date as a Cake Addin #addin nuget:?package=Ranges.Date&version=1.0.0 // Install Ranges.Date as a Cake Tool #tool nuget:?package=Ranges.Date&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Ranges.Date
An extremely small library that provides a Range implementation for dates (DateRange).
This is useful when you want to check if a DateTime is within a date range, e.g.
var xmas = new DateTime(2018, 12, 25);
if (range.Includes(xmas))
{
// Merry Christmas
}
For more information see:
- https://martinfowler.com/eaaDev/Range.html
- https://stackoverflow.com/questions/4781611/how-to-know-if-a-datetime-is-between-a-daterange-in-c-sharp
Installation
nuget install Ranges.Date
Full Example
using System;
using Xunit;
using Ranges.Date;
namespace Ranges.Tests
{
public class DateRangeTests
{
[Fact]
public void Include_Works()
{
var start = new DateTime(2018, 2, 1);
var end = new DateTime(2018, 2, 28);
var range = new DateRange(start, end);
Assert.False(range.Includes(new DateTime(2018, 1, 31)));
Assert.True(range.Includes(new DateTime(2018, 2, 1)));
Assert.True(range.Includes(new DateTime(2018, 2, 15)));
Assert.True(range.Includes(new DateTime(2018, 2, 28)));
Assert.False(range.Includes(new DateTime(2018, 3, 1)));
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has 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 |
---|---|---|
1.0.0 | 1,924 | 2/8/2018 |