-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support Duration
in Date.range/3
#14172
base: main
Are you sure you want to change the base?
support Duration
in Date.range/3
#14172
Conversation
72659ab
to
7650afb
Compare
Duration
in Date.range/3
7650afb
to
563fd96
Compare
@@ -119,6 +124,11 @@ defmodule Date do | |||
range(first, first_days, last, last_days, calendar, step) | |||
end | |||
|
|||
def range(%{calendar: calendar} = first, %Duration{} = duration) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we allow the keyword list version as well? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i found that range(~D[2020-01-01], [year: 1], 2)
looks a bit unergonomic, but definitely nothing speaking against allowing it 👍
lib/elixir/lib/calendar/date.ex
Outdated
@@ -149,6 +159,11 @@ defmodule Date do | |||
range(first, first_days, last, last_days, calendar, step) | |||
end | |||
|
|||
def range(%{calendar: calendar} = first, %Duration{} = duration, step) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably guard this too to check that step is a non-zero integer and update the ArgumentError clause & message?
No description provided.