Show dates in european format
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
Rafael Epplée 2025-12-02 16:59:46 +01:00
parent ee414c9440
commit e6c5a58c65
No known key found for this signature in database
GPG key ID: B4EFE6DC59FAE118
6 changed files with 54 additions and 11 deletions

View file

@ -0,0 +1,27 @@
defmodule MvWeb.Helpers.DateFormatter do
@moduledoc """
Centralized date formatting helper for the application.
Formats dates in European format (dd.mm.yyyy).
"""
use Gettext, backend: MvWeb.Gettext
@doc """
Formats a Date struct to European format (dd.mm.yyyy).
## Examples
iex> MvWeb.Helpers.DateFormatter.format_date(~D[2024-03-15])
"15.03.2024"
iex> MvWeb.Helpers.DateFormatter.format_date(nil)
""
"""
def format_date(%Date{} = date) do
Calendar.strftime(date, "%d.%m.%Y")
end
def format_date(nil), do: ""
def format_date(_), do: "Invalid date"
end