Table of Contents

NotableDateTimeOffsetExtensions Class

Definition

Namespace
Bodu.Extensions
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.0.1
Source
NotableDateTimeOffsetExtensions.AddWorkingDays.cs

Provides working-day, traversal, and notable-date query extension methods over DateTimeOffset, delegating to the DateOnly surface on the offset-local date component.

public static class NotableDateTimeOffsetExtensions
Inheritance
NotableDateTimeOffsetExtensions
Inherited Members

Examples

INotableDateService service = AmericasCalendarData.CreateService("US");
DateTimeOffset stamp = new(2026, 7, 3, 14, 0, 0, TimeSpan.FromHours(-5)); // observed Independence Day

bool working = stamp.IsWorkingDay(service, "US"); // false

// The next working day keeps the original time-of-day and -05:00 offset.
DateTimeOffset resume = stamp.NextWorkingDay(service, "US");

Remarks

The date component is the offset-local wall-clock date (DateTime). Traversal methods that return a moved DateTimeOffset preserve the original time-of-day and Offset.

Methods

AddWorkingDays(DateTimeOffset, int, INotableDateService, string, WeekPattern?)

Advances the date by a signed number of working days, preserving the time-of-day and offset.

public static DateTimeOffset AddWorkingDays(this DateTimeOffset date, int count, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The starting date.

count int

The number of working days to add; negative retreats, zero returns the date unchanged.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

DateTimeOffset

The resulting date at the original time-of-day and offset.

Exceptions

ArgumentNullException

service or territory is null.

EnumerateNotableDates(DateTimeOffset, DateTimeOffset, INotableDateService, string, NotableDateFilter?)

Resolves the notable dates emitted within the inclusive range for the territory.

public static IReadOnlyList<NotableDate> EnumerateNotableDates(this DateTimeOffset start, DateTimeOffset end, INotableDateService service, string territory, NotableDateFilter? filter = null)

Parameters

start DateTimeOffset

The inclusive start date.

end DateTimeOffset

The inclusive end date.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

filter NotableDateFilter

An optional filter the occurrences must satisfy.

Returns

IReadOnlyList<NotableDate>

The emitted occurrences, ordered by date then identity.

Exceptions

ArgumentNullException

service or territory is null.

EnumerateWorkingDays(DateTimeOffset, DateTimeOffset, INotableDateService, string, WeekPattern?)

Lazily enumerates the working days in the inclusive range, in ascending order, each at the start's time-of-day and offset.

public static IEnumerable<DateTimeOffset> EnumerateWorkingDays(this DateTimeOffset start, DateTimeOffset end, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

start DateTimeOffset

The inclusive start date.

end DateTimeOffset

The inclusive end date.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

IEnumerable<DateTimeOffset>

The working days in the range at the start's time-of-day and offset.

Exceptions

ArgumentNullException

service or territory is null.

GetNotableDates(DateTimeOffset, INotableDateService, string, NotableDateFilter?)

Gets the notable dates emitted on the date for the territory.

public static IReadOnlyList<NotableDate> GetNotableDates(this DateTimeOffset date, INotableDateService service, string territory, NotableDateFilter? filter = null)

Parameters

date DateTimeOffset

The value whose offset-local date is resolved.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

filter NotableDateFilter

An optional filter the occurrences must satisfy.

Returns

IReadOnlyList<NotableDate>

The emitted occurrences; empty when there are none.

Exceptions

ArgumentNullException

service or territory is null.

IsNonWorkingDay(DateTimeOffset, INotableDateService, string, WeekPattern?)

Determines whether the date is a non-working day for the territory.

public static bool IsNonWorkingDay(this DateTimeOffset date, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The value whose offset-local date is tested.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

bool

true if the date is non-working; otherwise false.

Exceptions

ArgumentNullException

service or territory is null.

IsNotableDate(DateTimeOffset, INotableDateService, string, NotableDateFilter?)

Determines whether any notable date is emitted on the date for the territory.

public static bool IsNotableDate(this DateTimeOffset date, INotableDateService service, string territory, NotableDateFilter? filter = null)

Parameters

date DateTimeOffset

The value whose offset-local date is tested.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

filter NotableDateFilter

An optional filter the occurrence must satisfy.

Returns

bool

true if at least one occurrence is emitted; otherwise false.

Exceptions

ArgumentNullException

service or territory is null.

IsWeekend(DateTimeOffset, WeekPattern?)

Determines whether the date falls outside the working week.

public static bool IsWeekend(this DateTimeOffset date, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The value whose offset-local date is tested.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

bool

true if the date is not a working-week day; otherwise false.

IsWorkingDay(DateTimeOffset, INotableDateService, string, WeekPattern?)

Determines whether the date is a working day for the territory.

public static bool IsWorkingDay(this DateTimeOffset date, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The value whose offset-local date is tested.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

bool

true if the date is a working day; otherwise false.

Exceptions

ArgumentNullException

service or territory is null.

NextWorkingDay(DateTimeOffset, INotableDateService, string, WeekPattern?)

Returns the first working day strictly after the date, preserving the time-of-day and offset.

public static DateTimeOffset NextWorkingDay(this DateTimeOffset date, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The starting date.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

DateTimeOffset

The next working day at the original time-of-day and offset.

Exceptions

ArgumentNullException

service or territory is null.

PreviousWorkingDay(DateTimeOffset, INotableDateService, string, WeekPattern?)

Returns the first working day strictly before the date, preserving the time-of-day and offset.

public static DateTimeOffset PreviousWorkingDay(this DateTimeOffset date, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The starting date.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

DateTimeOffset

The previous working day at the original time-of-day and offset.

Exceptions

ArgumentNullException

service or territory is null.

SnapToNearestWorkingDay(DateTimeOffset, INotableDateService, string, WeekPattern?)

Returns the date if it is a working day; otherwise the nearest working day, preserving the time-of-day and offset.

public static DateTimeOffset SnapToNearestWorkingDay(this DateTimeOffset date, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The date to snap.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

DateTimeOffset

The nearest working day at the original time-of-day and offset.

Exceptions

ArgumentNullException

service or territory is null.

SnapToWorkingDay(DateTimeOffset, INotableDateService, string, WeekPattern?)

Returns the date if it is a working day; otherwise the next working day, preserving the time-of-day and offset.

public static DateTimeOffset SnapToWorkingDay(this DateTimeOffset date, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The date to snap.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

DateTimeOffset

The date or the next working day, at the original time-of-day and offset.

Exceptions

ArgumentNullException

service or territory is null.

SnapToWorkingDayBackward(DateTimeOffset, INotableDateService, string, WeekPattern?)

Returns the date if it is a working day; otherwise the previous working day, preserving the time-of-day and offset.

public static DateTimeOffset SnapToWorkingDayBackward(this DateTimeOffset date, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

date DateTimeOffset

The date to snap.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

DateTimeOffset

The date or the previous working day, at the original time-of-day and offset.

Exceptions

ArgumentNullException

service or territory is null.

WorkingDaysBetween(DateTimeOffset, DateTimeOffset, INotableDateService, string, WeekPattern?)

Counts the working days in the inclusive range bounded by the two dates, regardless of their order.

public static int WorkingDaysBetween(this DateTimeOffset start, DateTimeOffset end, INotableDateService service, string territory, WeekPattern? workingWeek = null)

Parameters

start DateTimeOffset

One end of the range.

end DateTimeOffset

The other end of the range.

service INotableDateService

The service used to resolve notable dates.

territory string

The requested territory code.

workingWeek WeekPattern?

The working-week pattern, or null for Monday to Friday.

Returns

int

The number of working days in the inclusive range.

Exceptions

ArgumentNullException

service or territory is null.

Applies to

ProductVersions
.NET8, 10

See Also