Soenneker.Extensions.DateTimeOffsets.Years 11.0.159

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

Year-boundary extensions for DateTimeOffset, including boundaries defined by a supplied time zone.

Installation

dotnet add package Soenneker.Extensions.DateTimeOffsets.Years

Offset-preserving boundaries

Use the ordinary methods when the value's displayed year and existing offset are the intended frame of reference. No time-zone conversion occurs.

using Soenneker.Extensions.DateTimeOffsets.Years;

var value = new DateTimeOffset(2024, 6, 15, 12, 30, 0, TimeSpan.FromHours(-5));

DateTimeOffset start = value.ToStartOfYear();
// 2024-01-01 00:00:00 -05:00

DateTimeOffset end = value.ToEndOfYear();
// 2024-12-31 23:59:59.9999999 -05:00

Previous and next boundaries are available through ToStartOfPreviousYear(), ToEndOfPreviousYear(), ToStartOfNextYear(), and ToEndOfNextYear().

Time-zone year boundaries

Use the Tz methods when the input represents an instant and the supplied time zone determines its local year. Results are UTC DateTimeOffset values with a zero offset.

TimeZoneInfo eastern = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var instant = new DateTimeOffset(2024, 6, 15, 12, 30, 0, TimeSpan.Zero);

DateTimeOffset startUtc = instant.ToStartOfTzYear(eastern);
// 2024-01-01 05:00:00 +00:00

DateTimeOffset nextStartUtc = instant.ToStartOfNextTzYear(eastern);
// 2025-01-01 05:00:00 +00:00

The time-zone variants are ToStartOfTzYear(), ToEndOfTzYear(), ToStartOfPreviousTzYear(), ToEndOfPreviousTzYear(), ToStartOfNextTzYear(), and ToEndOfNextTzYear().

End methods are inclusive and return one tick before the following year begins. Every time-zone boundary is calculated from that local January 1, so historical offset and dateline changes are respected. A skipped local midnight resolves to the first valid local time, and an ambiguous midnight resolves to its earlier UTC occurrence.

Operations that would pass the DateTimeOffset range return DateTimeOffset.MinValue or DateTimeOffset.MaxValue instead of throwing.

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

Showing the top 2 NuGet packages that depend on Soenneker.Extensions.DateTimeOffsets.Years:

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

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.177 0 12/2/2026
11.0.176 0 12/2/2026
11.0.175 0 12/2/2026
11.0.174 55 12/2/2026
11.0.173 77 12/1/2026
11.0.172 69 12/1/2026
11.0.171 69 12/1/2026
11.0.170 92 12/1/2026
11.0.169 131 11/30/2026
11.0.168 323 11/19/2026
11.0.167 118 11/19/2026
11.0.166 159 11/18/2026
11.0.164 198 11/15/2026
11.0.163 151 11/15/2026
11.0.162 283 11/11/2026
11.0.161 163 11/11/2026
11.0.160 174 11/11/2026
11.0.159 123 11/11/2026
11.0.158 142 11/11/2026
11.0.157 113 11/11/2026
Loading failed

Update dependency Soenneker.Extensions.DateTimeOffsets to 11.0.201 (#321)