Soenneker.Extensions.DateTime.DayOfWeek 11.0.1531

Prefix Reserved
dotnet add package Soenneker.Extensions.DateTime.DayOfWeek --version 11.0.1531
                    
NuGet\Install-Package Soenneker.Extensions.DateTime.DayOfWeek -Version 11.0.1531
                    
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="Soenneker.Extensions.DateTime.DayOfWeek" Version="11.0.1531" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.DateTime.DayOfWeek" Version="11.0.1531" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.DateTime.DayOfWeek" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Extensions.DateTime.DayOfWeek --version 11.0.1531
                    
#r "nuget: Soenneker.Extensions.DateTime.DayOfWeek, 11.0.1531"
                    
#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.
#:package Soenneker.Extensions.DateTime.DayOfWeek@11.0.1531
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Extensions.DateTime.DayOfWeek&version=11.0.1531
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.DateTime.DayOfWeek&version=11.0.1531
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.DateTime.DayOfWeek

Moves a DateTime to the strictly previous or next occurrence of a weekday, with optional day boundaries and time-zone-aware UTC results.

Installation

dotnet add package Soenneker.Extensions.DateTime.DayOfWeek
using Soenneker.Extensions.DateTime.DayOfWeek;

System.DateTime monday = new(2026, 8, 31, 15, 30, 0, DateTimeKind.Utc);

System.DateTime previousFriday = monday.ToPreviousDayOfWeek(DayOfWeek.Friday);
System.DateTime nextMonday = monday.ToNextDayOfWeek(DayOfWeek.Monday);

Navigation is strict. If the input is already on the requested weekday, the previous/next result is seven days away. ToPreviousDayOfWeek() and ToNextDayOfWeek() preserve the time of day and Kind.

Use the boundary variants when the clock fields should be reset:

System.DateTime previousFridayStart = monday.ToStartOfPreviousDayOfWeek(DayOfWeek.Friday);
System.DateTime nextFridayEnd = monday.ToEndOfNextDayOfWeek(DayOfWeek.Friday);

Start methods return local clock midnight. End methods return one tick before the following date. These non-time-zone methods operate directly on the input fields and preserve Kind.

Time-zone-aware navigation

TimeZoneInfo eastern = TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
System.DateTime utc = new(2026, 8, 29, 18, 0, 0, DateTimeKind.Utc);

System.DateTime nextMondayStartUtc =
    utc.ToStartOfNextTzDayOfWeek(DayOfWeek.Monday, eastern);

System.DateTime previousFridayEndUtc =
    utc.ToEndOfPreviousTzDayOfWeek(DayOfWeek.Friday, eastern);

The time-zone variants first determine the input instant's local weekday, select the strictly previous or next matching local date, and return its boundary as a UTC DateTime:

  • ToStartOfPreviousTzDayOfWeek()
  • ToStartOfNextTzDayOfWeek()
  • ToEndOfPreviousTzDayOfWeek()
  • ToEndOfNextTzDayOfWeek()

If the input Kind is not Utc, its fields are treated as UTC rather than converted from the machine's local zone. Supply an actual UTC value to avoid ambiguity.

Boundaries use local calendar math. A midnight in a daylight-saving gap advances to the first valid local minute; an ambiguous midnight selects the earlier UTC instant. End values are one tick before the next valid local day boundary.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Extensions.DateTime.DayOfWeek:

Package Downloads
Soenneker.Extensions.DateTime.Suite

A collection of all the DateTime precision extension methods

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1531 36 11/14/2026
11.0.1530 65 11/14/2026
11.0.1529 265 11/11/2026
11.0.1528 74 11/11/2026
11.0.1527 85 11/11/2026
11.0.1526 68 11/11/2026
11.0.1525 92 11/11/2026
11.0.1524 84 11/11/2026
11.0.1523 81 11/11/2026
11.0.1520 121 11/10/2026
11.0.1519 728 11/3/2026
11.0.1518 111 11/3/2026
11.0.1517 110 11/3/2026
11.0.1516 224 10/27/2026
11.0.1515 115 10/27/2026
11.0.1514 121 10/27/2026
11.0.1513 106 10/26/2026
11.0.1511 106 10/26/2026
11.0.1510 103 10/26/2026
11.0.1509 108 10/26/2026
Loading failed

Update dependency Soenneker.Extensions.DateTime.Day to 11.0.2080 (#1957)