Skip to content

Commit

Permalink
Fix Cldr.Calendar.Kday.nth_kday/3
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed May 30, 2024
1 parent 1d7a920 commit cb8916c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/cldr/calendar/kday.ex
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ defmodule Cldr.Calendar.Kday do
|> date_from_iso_days(calendar)
end

def nth_kday(iso_days, n, k) when is_integer(iso_days) and n > 0 do
weeks_to_days(n) + kday_on_or_before(iso_days, k)
def nth_kday(gregorian_days, n, k) when is_integer(gregorian_days) and n > 0 do
kday_on_or_after(gregorian_days, k) + weeks_to_days(n - 1)
end

def nth_kday(iso_days, n, k) when is_integer(iso_days) and n < 0 do
weeks_to_days(n) + kday_on_or_after(iso_days, k)
def nth_kday(gregorian_days, n, k) when is_integer(gregorian_days) do
kday_on_or_before(gregorian_days, k) + weeks_to_days(n + 1)
end

@doc """
Expand Down

0 comments on commit cb8916c

Please sign in to comment.