Skip to content

Commit

Permalink
Fix #532 - shift priority incorrectly inverted
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Jun 27, 2019
1 parent 59650d4 commit 3fd2804
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/datetime/datetime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,15 @@ defimpl Timex.Protocol, for: DateTime do
end

# Consider compare_unit/2 an analog of Kernel.<=/2
defp compare_unit(:years, _), do: false
defp compare_unit(_, :years), do: true
defp compare_unit(:months, _), do: false
defp compare_unit(_, :months), do: true
defp compare_unit(:weeks, _), do: false
defp compare_unit(_, :weeks), do: true
defp compare_unit(:days, _), do: false
defp compare_unit(_, :days), do: true
# We want the largest units first
defp compare_unit(:years, _), do: true
defp compare_unit(_, :years), do: false
defp compare_unit(:months, _), do: true
defp compare_unit(_, :months), do: false
defp compare_unit(:weeks, _), do: true
defp compare_unit(_, :weeks), do: false
defp compare_unit(:days, _), do: true
defp compare_unit(_, :days), do: false

defp calculate_shift(shifts), do: calculate_shift(shifts, 0)

Expand Down

0 comments on commit 3fd2804

Please sign in to comment.