Vali-BusinessHours
1.0.0
dotnet add package Vali-BusinessHours --version 1.0.0
NuGet\Install-Package Vali-BusinessHours -Version 1.0.0
<PackageReference Include="Vali-BusinessHours" Version="1.0.0" />
<PackageVersion Include="Vali-BusinessHours" Version="1.0.0" />
<PackageReference Include="Vali-BusinessHours" />
paket add Vali-BusinessHours --version 1.0.0
#r "nuget: Vali-BusinessHours, 1.0.0"
#:package Vali-BusinessHours@1.0.0
#addin nuget:?package=Vali-BusinessHours&version=1.0.0
#tool nuget:?package=Vali-BusinessHours&version=1.0.0
Vali-BusinessHours
Resolves the simultaneous business-hours overlap window between two IANA timezones — the classic "what time works for both of us" cross-timezone scheduling problem.
Features
- Pairwise timezone overlap — given a daily business-hours block (
TimeOnlystart/end) per zone, resolves the UTC window where both are open at once - DST-correct — the offset of each zone is resolved at the specific instant evaluated (via
Vali-TimeZone), never a cached base offset - Midnight-crossing aware — a zone's business hours can map to the calendar day before or after the reference date once projected to the other zone; the overlap search checks all three candidate days
- Workday-aware variant —
OverlapOnWorkdayshort-circuits to "no overlap" when the reference date isn't a workday in either zone's ownVali-Calendar - Composes
Vali-CalendarandVali-TimeZonewithout coupling either package to the other - Compiled targets:
net8.0·net9.0·net10.0— compatible with .NET 6+ via NuGet backward compatibility
Installation
dotnet add package Vali-BusinessHours
Compatible with .NET 6, 7, 8, and 9. For new projects, .NET 8 (LTS) or .NET 9 is recommended.
Quick Start
using Vali_BusinessHours.Core;
using Vali_BusinessHours.Models;
using Vali_TimeZone.Core;
IValiTimeZone timeZone = new ValiTimeZone();
IValiBusinessHours businessHours = new ValiBusinessHours(timeZone);
var lima = new BusinessHoursWindow("America/Lima", new TimeOnly(9, 0), new TimeOnly(18, 0));
var madrid = new BusinessHoursWindow("Europe/Madrid", new TimeOnly(9, 0), new TimeOnly(18, 0));
BusinessHoursOverlapResult result = businessHours.Overlap(lima, madrid, new DateTime(2025, 6, 2));
if (result.HasOverlap)
{
Console.WriteLine($"Overlap (Lima time): {result.StartInZoneA} → {result.EndInZoneA}");
Console.WriteLine($"Overlap (Madrid time): {result.StartInZoneB} → {result.EndInZoneB}");
}
API Reference
Overlap(BusinessHoursWindow a, BusinessHoursWindow b, DateTime referenceDate)
Resolves the overlap for a calendar date, interpreted in a's timezone.
BusinessHoursOverlapResult Overlap(BusinessHoursWindow a, BusinessHoursWindow b, DateTime referenceDate);
OverlapOnWorkday((BusinessHoursWindow, IValiCalendar) a, (BusinessHoursWindow, IValiCalendar) b, DateTime referenceDate)
Same as Overlap, but requires referenceDate to be a workday in both calendars first — useful when each side has its own holiday calendar.
using Vali_Calendar.Core;
using Vali_Holiday.Core;
IValiCalendar peruCalendar = new ValiCalendar(holidayProvider: HolidayProviderFactory.CreateAll().For("PE"));
IValiCalendar spainCalendar = new ValiCalendar(holidayProvider: HolidayProviderFactory.CreateAll().For("ES"));
var result = businessHours.OverlapOnWorkday(
(lima, peruCalendar),
(madrid, spainCalendar),
new DateTime(2025, 6, 2));
BusinessHoursOverlapResult
| Member | Meaning |
|---|---|
HasOverlap |
true if the two windows share any instant. |
StartUtc / EndUtc |
The overlap window as absolute UTC instants. |
StartInZoneA / EndInZoneA |
The overlap window projected to the first window's zone. |
StartInZoneB / EndInZoneB |
The overlap window projected to the second window's zone. |
All members are null when HasOverlap is false.
v1 Scope
- Exactly two timezones per call. Three or more zones at once is out of scope for v1.
- A single daily business-hours block per zone — no recurrence, no per-day exceptions.
- No automatic holiday filtering inside
Overlap— combine with your ownIValiCalendar+IHolidayProvider(seeOverlapOnWorkday), or filter the reference date yourself. - No meeting-scheduling features (no calendars, invitees, or slot negotiation) — this is a calculation primitive, not a scheduling product.
Dependency Injection
// Program.cs
using Vali_BusinessHours.Extensions;
using Vali_TimeZone.Extensions;
builder.Services.AddValiTimeZone(); // IValiBusinessHours resolves IValiTimeZone from the container
builder.Services.AddValiBusinessHours(); // registers IValiBusinessHours as a singleton
License
Licensed under the MIT License. Copyright © 2025 Felipe Rafael Montenegro Morriberon. All rights reserved.
Donations
If this package is useful to you, consider supporting its development:
- Latin America — MercadoPago
- International — PayPal
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Vali-Calendar (>= 1.0.0)
- Vali-TimeZone (>= 1.0.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Vali-Calendar (>= 1.0.0)
- Vali-TimeZone (>= 1.0.0)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Vali-Calendar (>= 1.0.0)
- Vali-TimeZone (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Vali-BusinessHours:
| Package | Downloads |
|---|---|
|
Vali-Tempo
Vali-Tempo is the all-in-one meta-package for the Vali-Tempo ecosystem. Installing it gives you every module — Vali-Time, Vali-Range, Vali-Calendar, Vali-CountDown, Vali-Age, Vali-Holiday, Vali-TimeZone, Vali-Schedule, Vali-Duration, Vali-BusinessHours, and Vali-Bucket — with a single NuGet reference and a single DI registration call. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 135 | 10/14/2026 |
Vali-BusinessHours v1.0.0 — initial release: pairwise cross-timezone business-hours overlap (Overlap), workday-aware overlap (OverlapOnWorkday).