DateAndTimeExtensions 1.2.0

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

// Install DateAndTimeExtensions as a Cake Tool
#tool nuget:?package=DateAndTimeExtensions&version=1.2.0

DateAndTimeExtensions (C#)

Available via Nuget: https://www.nuget.org/packages/DateAndTimeExtensions

Little convenience helper extension methods for:

  • DateTime
  • DateOnly
  • TimeOnly

There are 2 type of extensions:

  • instance (parameter this)
  • class

However, C# unfortunately doesn't allow to extend static classes themselves.
This is why you need to call DateTimeExt, DateOnlyExt or TimeOnlyExt for the class variants (no this parameter).

If the classes would be named like their .NET counterparts you would have to constantly fully qualify the namespace which would be cumbersome.

Extension methods

DateTime

  • DaysFromNow(this DateTime dateTime):int
  • DaysFromToday(this DateTime dateTime):int
  • DaysFromUtcNow(this DateTime dateTime):int
  • DaysSinceNow(this DateTime dateTime):int
  • DaysSinceToday(this DateTime dateTime):int
  • DaysSinceUtcNow(this DateTime dateTime):int
  • EndOfDay(this DateTime dateTime):DateTime
  • EndOfMonth():DateTime
  • EndOfMonth(this DateTime dateTime):DateTime
  • EndOfToday():DateTime
  • EndOfYear():DateTime
  • EndOfYear(this DateTime dateTime):DateTime
  • IsWeekday():bool
  • IsWeekday(this DateTime dateTime):bool
  • IsWeekend():bool
  • IsWeekend(this DateTime dateTime):bool
  • LastOfMonth():DateTime
  • LastOfMonth(this DateTime dateTime):DateTime
  • LastOfYear():DateTime
  • LastOfYear(this DateTime dateTime):DateTime
  • NextWorkday():DateTime
  • NextWorkday(this DateTime dateTime):DateTime
  • PreviousWorkday():DateTime
  • PreviousWorkday(this DateTime dateTime):DateTime
  • SetTime(this DateTime dateTime, int hours, int minutes = 0, int seconds = 0, int milliseconds = 0):DateTime
  • StartOfDay(this DateTime dateTime):DateTime
  • StartOfMonth():DateTime
  • StartOfMonth(this DateTime dateTime):DateTime
  • StartOfYear():DateTime
  • StartOfYear(this DateTime dateTime):DateTime
  • Tomorrow:DateTime
  • TomorrowFromNow:DateTime
  • TomorrowFromUtcNow:DateTime
  • Yesterday:DateTime
  • YesterdayFromNow:DateTime
  • YesterdayFromUtcNow:DateTime

DateOnly

  • DaysFromToday(this DateOnly dateOnly):int
  • DaysSinceToday(this DateOnly dateOnly):int
  • FirstOfMonth():DateOnly
  • FirstOfMonth(this DateOnly dateOnly):DateOnly
  • FirstOfYear():DateOnly
  • FirstOfYear(this DateOnly dateOnly):DateOnly
  • IsWeekday():bool
  • IsWeekday(this DateOnly dateOnly):bool
  • IsWeekend():bool
  • IsWeekend(this DateOnly dateOnly):bool
  • LastOfMonth():DateOnly
  • LastOfMonth(this DateOnly dateOnly):DateOnly
  • LastOfYear():DateOnly
  • LastOfYear(this DateOnly dateOnly):DateOnly
  • NextWorkday():DateOnly
  • NextWorkday(this DateOnly dateOnly):DateOnly
  • PreviousWorkday():DateOnly
  • PreviousWorkday(this DateOnly dateOnly):DateOnly
  • Today:DateOnly
  • Tomorrow:DateOnly
  • Yesterday:DateOnly

TimeOnly

  • Midday:TimeOnly
  • Now:TimeOnly
  • UtcNow:TimeOnly
Product Compatible and additional computed target framework versions.
.NET 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.
  • 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
1.2.0 118 10/2/2023
1.1.0 94 10/2/2023
1.0.0 102 10/2/2023