From a727fa67cfd302ef48ed3d849e23cb75d588a27d Mon Sep 17 00:00:00 2001 From: shibao Date: Tue, 15 Feb 2022 17:30:58 -0500 Subject: [PATCH] fix bug with datetime helpers --- lib/cannery_web/live/live_helpers.ex | 8 ++++---- lib/cannery_web/views/view_helpers.ex | 28 ++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/cannery_web/live/live_helpers.ex b/lib/cannery_web/live/live_helpers.ex index 293caf9..3510da5 100644 --- a/lib/cannery_web/live/live_helpers.ex +++ b/lib/cannery_web/live/live_helpers.ex @@ -56,10 +56,10 @@ defmodule CanneryWeb.LiveHelpers do phx-key="escape" > <%= live_patch to: @return_to, - id: "close", - class: - "absolute top-8 right-10 text-gray-500 hover:text-gray-800 transition-all duration-500 ease-in-out", - phx_click: hide_modal() do %> + id: "close", + class: + "absolute top-8 right-10 text-gray-500 hover:text-gray-800 transition-all duration-500 ease-in-out", + phx_click: hide_modal() do %> <% end %> diff --git a/lib/cannery_web/views/view_helpers.ex b/lib/cannery_web/views/view_helpers.ex index 3f68539..f1a7505 100644 --- a/lib/cannery_web/views/view_helpers.ex +++ b/lib/cannery_web/views/view_helpers.ex @@ -19,15 +19,37 @@ defmodule CanneryWeb.ViewHelpers do ~H""" + """ + end + + @doc """ + Returns a element that renders the Date in the user's local + timezone with Alpine.js + """ + @spec display_date(Date.t()) :: Phoenix.LiveView.Rendered.t() + def display_date(date) do + assigns = %{date: date |> Date.to_iso8601(:extended)} + + ~H""" + """ end