Hi,

Not to self promote, but this is the *exact* use case I created CompareChain 
for:

https://hexdocs.pm/compare_chain/readme.html#background-and-motivation

import CompareChain

# excluding bounds
compare?(start_date < date < end_date, Date)

# including bounds
compare?(start_date <= date <= end_date, Date)

In case your proposal is not accepted, please consider trying it out as a 
substitute :)
On Friday, July 5, 2024 at 4:49:37 AM UTC-4 eomo...@gmail.com wrote:

> I have been extensively working with dates recently and found the need to 
> create a function between?/3. This function takes first_date, second_date, 
> and target_date as inputs and returns a boolean indicating whether 
> target_date is between first_date and second_date, inclusive of the 
> boundaries if specified.
>
> While the Timex library offers this functionality, the recently added 
> Calendar module in Elixir already provides most of the features I need, 
> except for this specific function. I believe it would be beneficial to 
> include this functionality in the Calendar module.
> Proposal
>
> *Function:* Calendar.between?/3
>
> *Description:* This function checks if target_date falls between 
> first_date and second_date. By default, the boundaries are exclusive. An 
> optional keyword list allows the inclusion of boundaries.
>
> *Example Usage:*
>
> *```elixir*
>
> Calendar.between?(datetime_1, datetime_2, datetime_3) 
>
> *```*
>
> Returns true if datetime_3 is between datetime_1 and datetime_2, 
> exclusive of datetime_1 and datetime_2.
>
> ```elixir
>
> Calendar.between?(datetime_1, datetime_2, datetime_3, inclusive: true)
>
> ```
>
> Of course, there are other factors to consider, but setting aside the 
> implementation details, what is the feasibility of adding this function?
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/8f8713b2-fbe3-4596-96eb-8fe185da7d33n%40googlegroups.com.

Reply via email to