Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tfiedlerdejanze
Copy link
Contributor

No description provided.

@tfiedlerdejanze tfiedlerdejanze force-pushed the date-range-with-durations branch from 72659ab to 7650afb Compare January 10, 2025 20:52
@tfiedlerdejanze tfiedlerdejanze changed the title support Duration in Date.range/3 support Duration in Date.range/3 Jan 10, 2025
@tfiedlerdejanze tfiedlerdejanze force-pushed the date-range-with-durations branch from 7650afb to 563fd96 Compare January 10, 2025 21:01
@@ -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
Copy link
Member

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? :)

Copy link
Contributor Author

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 👍

@@ -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
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants