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
<PackageReference Include="Soenneker.Extensions.DateTime.DayOfWeek" Version="11.0.1531" />
<PackageVersion Include="Soenneker.Extensions.DateTime.DayOfWeek" Version="11.0.1531" />
<PackageReference Include="Soenneker.Extensions.DateTime.DayOfWeek" />
paket add Soenneker.Extensions.DateTime.DayOfWeek --version 11.0.1531
#r "nuget: Soenneker.Extensions.DateTime.DayOfWeek, 11.0.1531"
#:package Soenneker.Extensions.DateTime.DayOfWeek@11.0.1531
#addin nuget:?package=Soenneker.Extensions.DateTime.DayOfWeek&version=11.0.1531
#tool nuget:?package=Soenneker.Extensions.DateTime.DayOfWeek&version=11.0.1531
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
Navigate by weekday
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.DateTime.Day (>= 11.0.2080)
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 |
Update dependency Soenneker.Extensions.DateTime.Day to 11.0.2080 (#1957)