Soenneker.Extensions.DateTimeOffsets.Weeks 11.0.164

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

Week-boundary and ISO week-number extensions for DateTimeOffset.

Installation

dotnet add package Soenneker.Extensions.DateTimeOffsets.Weeks

Offset-preserving boundaries

The non-time-zone methods use Monday as the first day of the week and preserve the input offset.

using Soenneker.Extensions.DateTimeOffsets.Weeks;

var value = new DateTimeOffset(2026, 3, 4, 12, 0, 0, TimeSpan.FromHours(-5));

DateTimeOffset start = value.ToStartOfWeek();
// Monday, 2026-03-02 00:00:00 -05:00

DateTimeOffset end = value.ToEndOfWeek();
// Sunday, 2026-03-08 23:59:59.9999999 -05:00

Previous and next boundaries are available through ToStartOfPreviousWeek(), ToEndOfPreviousWeek(), ToStartOfNextWeek(), and ToEndOfNextWeek().

Time-zone boundaries

The Tz methods first determine the input instant's local date in the supplied time zone, then return the corresponding boundary as a UTC DateTimeOffset. Monday is the default, but any DayOfWeek can be selected.

TimeZoneInfo eastern = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var instant = new DateTimeOffset(2026, 3, 4, 12, 0, 0, TimeSpan.Zero);

DateTimeOffset mondayStartUtc = instant.ToStartOfTzWeek(eastern);
DateTimeOffset sundayStartUtc = instant.ToStartOfTzWeek(eastern, DayOfWeek.Sunday);
DateTimeOffset nextMondayUtc = instant.ToStartOfNextTzWeek(eastern);

The same pattern is available for ToStartOfPreviousTzWeek(), ToEndOfTzWeek(), ToEndOfPreviousTzWeek(), and ToEndOfNextTzWeek().

Time-zone boundaries use local calendar days, not fixed 168-hour durations, so daylight-saving changes do not shift local midnight. End methods are inclusive and return one tick before the following week begins. A skipped local midnight resolves to the first valid local time; an ambiguous midnight resolves to its earlier UTC occurrence.

ISO week numbers

int utcWeek = instant.ToUtcWeekNumber();
int easternWeek = instant.ToTzWeekNumber(eastern);

Both methods use ISO 8601 week numbering: weeks begin Monday, and week 1 is the week containing January 4. ToTzWeekNumber() uses the date in the supplied time zone, so it can differ from the UTC week number near day and year boundaries.

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 (3)

Showing the top 3 NuGet packages that depend on Soenneker.Extensions.DateTimeOffsets.Weeks:

Package Downloads
Soenneker.Extensions.DateRangeType

A collection of helpful DateRangeType enum extension methods

Soenneker.Extensions.DateTimeOffsets.Suite

A collection of all of the helpful DateTimeOffset extension methods

Soenneker.Utils.DateTimeOffsets

Helpful utility methods surrounding DateTimeOffsets

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.188 0 12/2/2026
11.0.187 0 12/2/2026
11.0.186 0 12/2/2026
11.0.184 57 12/2/2026
11.0.183 107 12/1/2026
11.0.182 105 12/1/2026
11.0.181 115 12/1/2026
11.0.180 88 12/1/2026
11.0.179 67 11/30/2026
11.0.178 129 11/30/2026
11.0.177 320 11/19/2026
11.0.176 162 11/19/2026
11.0.175 122 11/18/2026
11.0.172 240 11/15/2026
11.0.171 214 11/15/2026
11.0.169 318 11/11/2026
11.0.168 164 11/11/2026
11.0.167 144 11/11/2026
11.0.166 171 11/11/2026
11.0.164 226 11/10/2026
Loading failed

Disable .NET CLI telemetry and welcome messages in workflows