summaryrefslogtreecommitdiff
path: root/lib/lsg_web/views
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lsg_web/views')
-rw-r--r--lib/lsg_web/views/alcoolog_view.ex4
-rw-r--r--lib/lsg_web/views/layout_view.ex17
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/lsg_web/views/alcoolog_view.ex b/lib/lsg_web/views/alcoolog_view.ex
new file mode 100644
index 0000000..2c55c09
--- /dev/null
+++ b/lib/lsg_web/views/alcoolog_view.ex
@@ -0,0 +1,4 @@
+defmodule LSGWeb.AlcoologView do
+ use LSGWeb, :view
+end
+
diff --git a/lib/lsg_web/views/layout_view.ex b/lib/lsg_web/views/layout_view.ex
index 39216ed..956d703 100644
--- a/lib/lsg_web/views/layout_view.ex
+++ b/lib/lsg_web/views/layout_view.ex
@@ -1,3 +1,20 @@
defmodule LSGWeb.LayoutView do
use LSGWeb, :view
+
+ def format_time(date, with_relative \\ true) do
+ alias Timex.Format.DateTime.Formatters
+ alias Timex.Timezone
+ date = if is_integer(date) do
+ date
+ |> DateTime.from_unix!(:millisecond)
+ |> Timezone.convert("Europe/Paris")
+ else
+ date
+ end
+ {:ok, relative} = Formatters.Relative.relative_to(date, Timex.now("Europe/Paris"), "{relative}", "fr")
+ {:ok, detail} = Formatters.Default.lformat(date, "{D}/{M}/{YYYY} {h24}:{m}", "fr")
+
+ content_tag(:time, if(with_relative, do: relative, else: detail), [title: detail])
+ end
+
end