fix datetime parsing

This commit is contained in:
byte[] 2019-11-30 20:30:05 -05:00
parent 9b87f9a07a
commit 8b79f5808f
4 changed files with 7 additions and 7 deletions

View file

@ -5,7 +5,7 @@ defmodule PhilomenaWeb.CommentController do
import Ecto.Query
def index(conn, params) do
cq = params["cq"] || "created_at.gt:1 week ago"
cq = params["cq"] || "created_at.gte:1 week ago"
{:ok, query} = Query.compile(conn.assigns.current_user, cq)

View file

@ -2,7 +2,7 @@ h1 Comments
= form_for :comments, Routes.comment_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f ->
.field
= text_input f, :cq, name: :cq, value: @conn.params["cq"] || "created_at.gt:1 week ago", class: "input hform__text", placeholder: "Search comments", autocapitalize: "none"
= text_input f, :cq, name: :cq, value: @conn.params["cq"] || "created_at.gte:1 week ago", class: "input hform__text", placeholder: "Search comments", autocapitalize: "none"
= submit "Search", class: "hform__button button", data: [disable_with: false]
.fieldlabel

View file

@ -91,10 +91,10 @@ defmodule Search.DateParser do
end
defp relative_datetime([count, scale]) do
now = NaiveDateTime.utc_now()
now = DateTime.utc_now()
lower = NaiveDateTime.add(now, count * -scale, :second)
upper = NaiveDateTime.add(now, (count - 1) * -scale, :second)
lower = DateTime.add(now, count * -scale, :second)
upper = DateTime.add(now, (count - 1) * -scale, :second)
[lower, upper]
end