Soenneker.Extensions.DateTimeOffsets.DayOfWeeks 4.0.115

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.DateTimeOffsets.DayOfWeeks --version 4.0.115
                    
NuGet\Install-Package Soenneker.Extensions.DateTimeOffsets.DayOfWeeks -Version 4.0.115
                    
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.115" />
                    
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.115" />
                    
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.115
                    
#r "nuget: Soenneker.Extensions.DateTimeOffsets.DayOfWeeks, 4.0.115"
                    
#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.115
                    
#: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.115
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.DateTimeOffsets.DayOfWeeks&version=4.0.115
                    
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.120 91 9/1/2026
4.0.119 115 9/1/2026
4.0.118 101 8/31/2026
4.0.117 107 8/31/2026
4.0.116 96 8/31/2026
4.0.115 154 8/30/2026
4.0.114 208 8/30/2026
4.0.113 89 8/29/2026
4.0.112 82 8/29/2026
4.0.111 82 8/29/2026
4.0.110 339 8/26/2026
4.0.109 186 8/26/2026
4.0.108 225 8/22/2026
4.0.107 168 8/21/2026
4.0.106 659 8/19/2026
4.0.105 149 8/18/2026
4.0.104 185 8/18/2026
4.0.103 113 8/18/2026
4.0.102 238 8/13/2026
4.0.101 245 8/9/2026
Loading failed

Update dependency Soenneker.Extensions.DateTimeOffsets.Days to 4.0.135 (#274)