Soenneker.Extensions.DateTimeOffsets.DayOfWeeks 4.0.132

Prefix Reserved
dotnet add package Soenneker.Extensions.DateTimeOffsets.DayOfWeeks --version 4.0.132
                    
NuGet\Install-Package Soenneker.Extensions.DateTimeOffsets.DayOfWeeks -Version 4.0.132
                    
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.DateTimeOffsets.DayOfWeeks" Version="4.0.132" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.DateTimeOffsets.DayOfWeeks" Version="4.0.132" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.DateTimeOffsets.DayOfWeeks" />
                    
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.DateTimeOffsets.DayOfWeeks --version 4.0.132
                    
#r "nuget: Soenneker.Extensions.DateTimeOffsets.DayOfWeeks, 4.0.132"
                    
#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.DateTimeOffsets.DayOfWeeks@4.0.132
                    
#: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.DateTimeOffsets.DayOfWeeks&version=4.0.132
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.DateTimeOffsets.DayOfWeeks&version=4.0.132
                    
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.DateTimeOffsets.DayOfWeeks

Moves a DateTimeOffset 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.DateTimeOffsets.DayOfWeeks
using Soenneker.Extensions.DateTimeOffsets.DayOfWeeks;

DateTimeOffset monday = new(2026, 8, 31, 15, 30, 0, TimeSpan.FromHours(-4));

DateTimeOffset previousFriday = monday.ToPreviousDayOfWeek(DayOfWeek.Friday);
DateTimeOffset nextMonday = monday.ToNextDayOfWeek(DayOfWeek.Monday);
DateTimeOffset previousFridayStart = monday.ToStartOfPreviousDayOfWeek(DayOfWeek.Friday);
DateTimeOffset nextFridayEnd = monday.ToEndOfNextDayOfWeek(DayOfWeek.Friday);

Navigation is strict. If the input is already on the requested weekday, the result is seven days away.

ToPreviousDayOfWeek() and ToNextDayOfWeek() preserve the input time and offset. Start/end variants reset the stored clock fields to midnight or one tick before the following date while preserving that offset. These methods do not apply a named time zone's DST rules.

TimeZoneInfo eastern = TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
DateTimeOffset instant = new(2026, 8, 29, 18, 0, 0, TimeSpan.Zero);

DateTimeOffset nextMondayStartUtc =
    instant.ToStartOfNextTzDayOfWeek(DayOfWeek.Monday, eastern);

DateTimeOffset previousFridayEndUtc =
    instant.ToEndOfPreviousTzDayOfWeek(DayOfWeek.Friday, eastern);

The time-zone variants determine the instant's local date, select the strictly previous or next matching weekday, and return the boundary with offset +00:00:

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

Starts resolve local midnight using the zone's rules. A midnight in a gap advances to the first valid local time; an ambiguous midnight selects the earlier UTC instant. Ends are one tick before the next valid local day boundary, so 23-hour and 25-hour days are handled without assuming a fixed 24-hour duration.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
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.DateTimeOffsets.DayOfWeeks:

Package Downloads
Soenneker.Extensions.DateTimeOffsets.Suite

A collection of all of the helpful DateTimeOffset extension methods

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.132 0 9/12/2026
4.0.131 65 9/10/2026
4.0.130 97 9/9/2026
4.0.129 175 9/8/2026
4.0.128 126 9/8/2026
4.0.127 151 9/7/2026
4.0.126 153 9/7/2026
4.0.125 80 9/7/2026
4.0.124 136 9/7/2026
4.0.123 291 9/5/2026
4.0.120 272 9/1/2026
4.0.119 157 9/1/2026
4.0.118 133 8/31/2026
4.0.117 129 8/31/2026
4.0.116 125 8/31/2026
4.0.115 193 8/30/2026
4.0.114 243 8/30/2026
4.0.113 101 8/29/2026
4.0.112 95 8/29/2026
4.0.111 95 8/29/2026
Loading failed

Use NuGet trusted publishing in publishing workflows