Adjust any non-working days to a nearby business day in a given calendar
Source:R/adjust_to_bizday.R
adjust_to_bizday.RdAdjust any non-working days to a nearby business day in a given calendar
Usage
adjust_to_bizday(
date,
calendar,
bdc = c("Preceding", "ModifiedPreceding", "ModifiedFollowing", "Following",
"Unadjusted", "HalfMonthModifiedFollowing", "Nearest")
)Arguments
- date
A vector of dates (Date object or coercible with
as.Date()).- calendar
(character) A QuantLib calendar id (the vector qlcal::calendars lists all valid options).
- bdc
(character) A QuantLib business-day convention. Defaults to
"Preceding": the previous business day, even if that falls in the prior month. See the QuantLib weekday correction docs for the other conventions.
Value
A vector of Date objects, the same length as date, with any
non-working dates adjusted according to bdc. Working days are left
unchanged.
Examples
# July 4 is a US holiday, but not a UK holiday
adjust_to_bizday(c("2025-07-03", "2025-07-04"), "UnitedStates")
#> [1] "2025-07-03" "2025-07-03"
adjust_to_bizday(c("2025-07-03", "2024-07-04"), "UnitedKingdom")
#> [1] "2025-07-03" "2024-07-04"
# a month-end weekend stays in its own month
adjust_to_bizday("2025-08-30", "UnitedStates")
#> [1] "2025-08-29"
adjust_to_bizday("2025-08-30", "UnitedStates", bdc = "Following")
#> [1] "2025-09-02"