Class BusinessDayExtensions
- Namespace
- HeroKit.Globalization
- Assembly
- HeroKit.dll
Public holiday and business day helpers based on the IHolidayCalendar of a Country.
public static class BusinessDayExtensions
- Inheritance
-
BusinessDayExtensions
- Inherited Members
Remarks
Business days are non-weekend days without a full-day holiday. Half-day holidays count as business days. Methods throw ArgumentOutOfRangeException for years the calendar does not cover and NotSupportedException when the country has no calendar.
Methods
AddBusinessDays(DateOnly, int, Country)
Moves a date by a number of business days. Negative values move backward.
public static DateOnly AddBusinessDays(this DateOnly value, int days, Country country)
Parameters
valueDateOnlyThe start date. It does not need to be a business day.
daysintThe number of business days to move.
countryCountryThe country.
Returns
- DateOnly
The resulting business day, or
valuewhendaysis zero.
Examples
new DateOnly(2026, 3, 19).AddBusinessDays(1, Countries.Turkey); // 2026-03-23
AddBusinessDays(DateTime, int, Country)
Moves a date by a number of business days. The time part and DateTimeKind are kept.
public static DateTime AddBusinessDays(this DateTime value, int days, Country country)
Parameters
valueDateTimeThe start date and time.
daysintThe number of business days to move.
countryCountryThe country.
Returns
- DateTime
The resulting date and time.
BusinessDaysUntil(DateOnly, DateOnly, Country)
Counts the business days after start up to and including end. A half-day holiday counts as a full day.
[Obsolete("Use CountBusinessDays, which counts a half-day holiday as 0.5. BusinessDaysUntil will be removed in 4.0.")]
public static int BusinessDaysUntil(this DateOnly start, DateOnly end, Country country)
Parameters
startDateOnlyThe start date (not counted).
endDateOnlyThe end date (counted if it is a business day).
countryCountryThe country.
Returns
- int
The number of business days; negative when
endis earlier.
CountBusinessDays(DateOnly, DateOnly, Country)
Counts the business days after start up to and including end.
A half-day holiday on a weekday, for example the eve (arife) of a Turkish religious holiday, counts as 0.5.
public static decimal CountBusinessDays(this DateOnly start, DateOnly end, Country country)
Parameters
startDateOnlyThe start date (not counted).
endDateOnlyThe end date (counted if it is a business day).
countryCountryThe country.
Returns
- decimal
The number of business days; negative when
endis earlier.
Examples
// Tue 27, Wed 28 (eve of Republic Day, half day), Thu 29 (holiday), Fri 30 October 2026
new DateOnly(2026, 10, 26).CountBusinessDays(new DateOnly(2026, 10, 30), Countries.Turkey); // 2.5
CountBusinessDays(DateTime, DateTime, Country)
Counts the business days between the dates of two DateTime values. See CountBusinessDays(DateOnly, DateOnly, Country); the time parts are ignored.
public static decimal CountBusinessDays(this DateTime start, DateTime end, Country country)
Parameters
startDateTimeThe start (its date is not counted).
endDateTimeThe end (its date is counted if it is a business day).
countryCountryThe country.
Returns
- decimal
The number of business days; negative when
endis earlier.
GetPublicHoliday(DateOnly, Country)
Returns the public holiday on a date, including half days.
public static PublicHoliday? GetPublicHoliday(this DateOnly value, Country country)
Parameters
Returns
- PublicHoliday?
The holiday, or null.
Examples
new DateOnly(2026, 3, 20).GetPublicHoliday(Countries.Turkey)?.Name; // "Ramazan Bayramı 1. Gün"
GetPublicHoliday(DateTime, Country)
Returns the public holiday on the date of a DateTime, including half days. The time part is ignored.
public static PublicHoliday? GetPublicHoliday(this DateTime value, Country country)
Parameters
Returns
- PublicHoliday?
The holiday, or null.
IsBusinessDay(DateOnly, Country)
Checks whether a date is a business day.
public static bool IsBusinessDay(this DateOnly value, Country country)
Parameters
Returns
- bool
True for business days; otherwise false.
IsBusinessDay(DateTime, Country)
Checks whether a date is a business day. The time part is ignored.
public static bool IsBusinessDay(this DateTime value, Country country)
Parameters
Returns
- bool
True for business days; otherwise false.
IsHalfDayHoliday(DateOnly, Country)
Checks whether a date is a half-day holiday, for example the eve (arife) of a Turkish religious holiday.
public static bool IsHalfDayHoliday(this DateOnly value, Country country)
Parameters
Returns
- bool
True for half-day holidays; otherwise false.
IsHalfDayHoliday(DateTime, Country)
Checks whether the date of a DateTime is a half-day holiday. The time part is ignored.
public static bool IsHalfDayHoliday(this DateTime value, Country country)
Parameters
Returns
- bool
True for half-day holidays; otherwise false.
IsPublicHoliday(DateOnly, Country)
Checks whether a date is a full-day public holiday.
public static bool IsPublicHoliday(this DateOnly value, Country country)
Parameters
Returns
- bool
True for full-day holidays; false for half days and ordinary days.
IsPublicHoliday(DateTime, Country)
Checks whether a date is a full-day public holiday. The time part is ignored.
public static bool IsPublicHoliday(this DateTime value, Country country)
Parameters
Returns
- bool
True for full-day holidays; otherwise false.