Timex.between/4? is super helpful function, but it falls flat on comparisons for periodic events (think cron-like daily scheduling) that use Time.t to set up boundaries of such period.
I.e. check like 23:00 <= 01:00 <= 03:00 would return false, which is fine for default behaviour, but requires extra code for usecases like above.
This PR introduces function's option cycled: true that takes into account if start and end are on different sides of midnight and makes above comparisons possible with a single function call.
With default options (cycled: false), this change is backward compatible.
Checklist
[X] Same for documentation, including moduledocs
[X] Tests were added or updated to cover changes
[X] Commits were squashed into a single coherent commit
[X] Notes added to CHANGELOG file which describe changes at a high-level
Summary of changes
Timex.between/4?
is super helpful function, but it falls flat on comparisons for periodic events (thinkcron
-like daily scheduling) that useTime.t
to set up boundaries of such period.I.e. check like
23:00 <= 01:00 <= 03:00
would returnfalse
, which is fine for default behaviour, but requires extra code for usecases like above.This PR introduces function's option
cycled: true
that takes into account ifstart
andend
are on different sides of midnight and makes above comparisons possible with a single function call.With default options (
cycled: false
), this change is backward compatible.Checklist