Ranges.Date 1.0.0

Extremely small library that provides a DateRange implementation

Install-Package Ranges.Date -Version 1.0.0
dotnet add package Ranges.Date --version 1.0.0
<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, C# scripting and .NET Interactive. 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

alt

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:

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)));
        }
    }
}

Ranges.Date

alt

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:

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)));
        }
    }
}

Dependencies

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 History

Version Downloads Last updated
1.0.0 688 2/8/2018