Soenneker.Utils.DateTime 11.0.1527

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

Soenneker.Utils.DateTime

Static helpers for constructing UTC timestamps and splitting ranges into timezone-aligned weeks or months.

Installation

dotnet add package Soenneker.Utils.DateTime

Construct timestamps

CreateUtcDateTime() builds a UTC DateTime. Any omitted component is taken from one snapshot of DateTime.UtcNow:

DateTime start = DateTimeUtil.CreateUtcDateTime(
    year: 2026,
    month: 4,
    day: 15,
    hour: 9,
    minute: 30,
    second: 0);

CreateTzDateTime() interprets the components as wall-clock time in a timezone and returns the corresponding UTC instant:

TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById("America/Chicago");

DateTime utc = DateTimeUtil.CreateTzDateTime(
    zone,
    year: 2026,
    month: 4,
    day: 15,
    hour: 9,
    minute: 30,
    second: 0);

Omitted components use the current wall-clock values in that timezone. Standard TimeZoneInfo rules apply: invalid local times during a daylight-saving transition throw, and ambiguous local times use the platform's normal conversion behavior.

Calendar ranges

List<(DateTime startAt, DateTime endAt)> weeks =
    DateTimeUtil.GetWeeklyDateTimesBetween(startAt, endAt, zone);

List<(DateTime startAt, DateTime endAt)> months =
    DateTimeUtil.GetMonthlyDateTimesBetween(startAt, endAt, zone);

Each method first expands startAt to the timezone-aligned start and end of its containing calendar period, then adds complete periods until one contains endAt. The returned ranges are calendar buckets rather than intersections with the input range, so the first start may precede startAt and the final end may follow endAt.

Both methods return at least the period containing startAt, including when endAt is earlier than that period's end. Validate range ordering before calling when an inverted range should be rejected.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1527 0 11/15/2026
11.0.1526 40 11/14/2026
11.0.1525 151 11/11/2026
11.0.1522 65 11/11/2026
11.0.1521 53 11/11/2026
11.0.1520 52 11/11/2026
11.0.1519 57 11/11/2026
11.0.1518 100 11/11/2026
11.0.1516 81 11/11/2026
11.0.1515 349 11/3/2026
11.0.1514 96 11/3/2026
11.0.1513 100 11/3/2026
11.0.1512 95 11/3/2026
11.0.1511 368 10/27/2026
11.0.1510 103 10/27/2026
11.0.1509 146 10/26/2026
11.0.1508 105 10/26/2026
11.0.1506 117 10/26/2026
11.0.1505 96 10/26/2026
11.0.1504 95 10/26/2026
Loading failed

Update dependency Soenneker.Extensions.DateTime.Week to 11.0.1678 (#1516)