mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
Fix leap year search bug
This commit is contained in:
parent
8da6cab713
commit
e668881c18
1 changed files with 9 additions and 1 deletions
|
@ -30,6 +30,13 @@ defmodule Philomena.Search.DateParser do
|
|||
defp timezone_bounds([tz_off, tz_hour]), do: [tz_off, tz_hour, 0]
|
||||
defp timezone_bounds([tz_off, tz_hour, tz_minute]), do: [tz_off, tz_hour, tz_minute]
|
||||
|
||||
defp days_in_year(year) do
|
||||
case Calendar.ISO.leap_year?(year) do
|
||||
true -> 366
|
||||
_ -> 365
|
||||
end
|
||||
end
|
||||
|
||||
defp days_in_month(year, month) when month in 1..12 do
|
||||
Calendar.ISO.days_in_month(year, month)
|
||||
end
|
||||
|
@ -50,7 +57,8 @@ defmodule Philomena.Search.DateParser do
|
|||
end
|
||||
|
||||
defp date_bounds([year]) do
|
||||
lower_upper({{year, 1, 1}, {0, 0, 0}}, 31_536_000)
|
||||
days = days_in_year(year)
|
||||
lower_upper({{year, 1, 1}, {0, 0, 0}}, 86_400 * days)
|
||||
end
|
||||
|
||||
defp date_bounds([year, month]) do
|
||||
|
|
Loading…
Reference in a new issue