Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ false
julia> isbday(BusinessDays.USSettlement(), Date(2015, 1, 1))
false

# Adjust to next business day
# Adjust to next business day (or return date if already a business day)
julia> tobday(:USSettlement, Date(2015, 1, 1))
2015-01-02

# Adjust to last business day
# Adjust to last business day (or return date if already a business day)
julia> tobday(:USSettlement, Date(2015, 1, 1); forward = false)
2014-12-31

Expand Down
7 changes: 7 additions & 0 deletions src/bdays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ Counts the number of Business Days between `dt0` and `dt1`.
Returns `Int`.

Computation is always based on next Business Day if given dates are not Business Days.

!!! note "Counting Convention"
The first Business Day is excluded from the count, e.g. if `dt0` and `dt1`
are the same date, `bdayscount` will always return 0. This convention is
different from [`listbdays`](@ref) which *is* inclusive. In our
`dt0 == dt1` example, if the date is a Business Day then `listbdays` will
return a 1-element Vector with that date.
"""
function bdayscount(hc::HolidayCalendar, dt0::Dates.Date, dt1::Dates.Date) :: Int
if _getcachestate(hc)
Expand Down
6 changes: 3 additions & 3 deletions src/query.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ listholidays(calendar, dt0::Dates.Date, dt1::Dates.Date) = listholidays(convert(
"""
listbdays(calendar, dt0::Dates.Date, dt1::Dates.Date) → Vector{Dates.Date}

Returns the list of business days between `dt0` and `dt1`.
Returns the list of business days between `dt0` and `dt1` (inclusive).
"""
function listbdays(hc::HolidayCalendar, dt0::Dates.Date, dt1::Dates.Date)
d = tobday(hc, min(dt0, dt1))
d1 = max(dt0, dt1)
d, d1 = minmax(dt0, dt1)
d = tobday(hc, d)

# empty result
if d > d1
Expand Down