Leovaria.Extensions.DateOnlyExtensions 8.0.0

dotnet add package Leovaria.Extensions.DateOnlyExtensions --version 8.0.0                
NuGet\Install-Package Leovaria.Extensions.DateOnlyExtensions -Version 8.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="Leovaria.Extensions.DateOnlyExtensions" Version="8.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Leovaria.Extensions.DateOnlyExtensions --version 8.0.0                
#r "nuget: Leovaria.Extensions.DateOnlyExtensions, 8.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 Leovaria.Extensions.DateOnlyExtensions as a Cake Addin
#addin nuget:?package=Leovaria.Extensions.DateOnlyExtensions&version=8.0.0

// Install Leovaria.Extensions.DateOnlyExtensions as a Cake Tool
#tool nuget:?package=Leovaria.Extensions.DateOnlyExtensions&version=8.0.0                

MIT License

Leovaria DateOnly Extensions

The Leovaria.Extensions.DateOnlyExtensions package provides numerous extension methods for the DateOnly struct in .NET which allows users to easily calculate certain dates, get upcoming or previous dates, check if there is anything special with certain dates, and more.

Users that work with a lot of date logic will hopefully find this package useful.

[!IMPORTANT] This package strictly uses the Gregorian Calendar to calculate date logic from. While the package may work for other calendars in some cases as well, it has not been tested for those. If many users would like to have support for other calendars, let me know and I'd be happy to look into adding support for those as well.

Some Method Examples

IsWeekendDay()

var date = new DateOnly(2024, 03, 21); // Thursday.
return date.IsWeekendDay(); // Produces boolean 'false'.
var date = new DateOnly(2024, 03, 23); // Saturday.
return date.IsWeekendDay(); // Produces boolean 'true'.

GetLastDateOfMonth()

var date = new DateOnly(2024, 03, 21);
return date.GetLastDateOfMonth(); // Produces DateOnly instance of 03/31/2024.

GetNextLeapYearDate()

var date = new DateOnly(2024, 09, 08);
return date.GetNextLeapYearDate(); // Produces DateOnly instance of 02/29/2028.

IsLeapDay()

var date = new DateOnly(2024, 02, 29);
return date.IsLeapDay(); // Produces boolean 'true'.
var date = new DateOnly(2024, 01, 24);
return date.IsLeapDay(); // Produces boolean 'false'.

GetNextWeekendDates()

var date = new DateOnly(2024, 03, 21);
return date.GetNextWeekendDates();
// Produces List of DateOnly instances with
// values 03/23/2024 and 03/24/2024.

GetDaysUntil(DateOnly untilDate)

var date = new DateOnly(2024, 03, 21);
var untilDate = new DateOnly(2024, 04, 01);
return date.GetDaysUntil(untilDate); // Produces int '11'.

AddWeeks(int weeks)

var date = new DateOnly(2024, 03, 01);
return date.AddWeeks(1); // Produces DateOnly instance of 03/08/2024.

AddFortnights(int fortnights)

var date = new DateOnly(2024, 03, 01);
return date.AddFortnights(1); // Produces DateOnly instance of 03/15/2024.

For more examples view the test directory for this at: https://github.com/bradleyleopold/Leovaria.Extensions/tree/937bb03a8dd0ff93da6deb6c1f3ed35c1e383ee9/Tests/Leovaria.Extensions.DateOnlyExtensions.Tests

Special Thanks

  • readme.so for giving me an easy tool to write this readme with.
  • shields.io for providing a nice License MIT badge.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.
  • net8.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
8.0.0 117 3/24/2024