fix error in search parser when using 0 for day/month, fix link to search syntax page on search form

This commit is contained in:
byte[] 2019-12-31 23:44:28 -05:00
parent 7000be9865
commit fb33238f72
2 changed files with 11 additions and 4 deletions

View file

@ -37,7 +37,7 @@ h1 Search
a data-search-add="my:watched" data-search-show-help=" " My watched tags
.flex__right
a href="#" data-click-toggle="#js-search-tags" Quick tags
a href="/search/syntax" Help
a href="/pages/search_syntax" Help
.block__content
.hidden.walloftext data-search-help="numeric"

View file

@ -1,6 +1,8 @@
defmodule Search.DateParser do
import NimbleParsec
defp to_int(input), do: Search.Helpers.to_int(input)
defp build_datetime(naive, tz_off, tz_hour, tz_minute) do
tz_hour =
tz_hour
@ -103,9 +105,14 @@ defmodule Search.DateParser do
choice([string(" "), string("\t"), string("\n"), string("\r"), string("\v"), string("\f")])
|> ignore()
pos_2dig_int =
ascii_char('123456789')
|> ascii_char('0123456789')
|> reduce(:to_int)
year = integer(4)
month = integer(2)
day = integer(2)
month = pos_2dig_int
day = pos_2dig_int
hour = integer(2)
minute = integer(2)
@ -186,4 +193,4 @@ defmodule Search.DateParser do
|> label("a RFC3339 datetime fragment, like `2019-01-01', or relative date, like `3 days ago'")
defparsec :parse, date
end
end