mix format

This commit is contained in:
Mirai Kumiko 2025-06-08 10:58:48 +02:00
parent 7d8cb33405
commit 4fb1e200f1
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
12 changed files with 221 additions and 69 deletions

View file

@ -25,12 +25,19 @@ defmodule NullaWeb.UserHTML do
relative =
cond do
diff == 0 -> "today"
diff == 1 -> "1 day ago"
diff < 30 -> "#{diff} days ago"
diff == 0 ->
"today"
diff == 1 ->
"1 day ago"
diff < 30 ->
"#{diff} days ago"
diff < 365 ->
months = Timex.diff(now, date, :months)
if months == 1, do: "1 month ago", else: "#{months} months ago"
true ->
years = Timex.diff(now, date, :years)
if years == 1, do: "1 year ago", else: "#{years} years ago"
@ -46,7 +53,7 @@ defmodule NullaWeb.UserHTML do
def format_note_datetime_diff(datetime) do
now = Timex.now()
diff = Timex.diff(now, datetime, :seconds)
cond do
diff < 60 ->
"now"
@ -59,15 +66,15 @@ defmodule NullaWeb.UserHTML do
hours = div(diff, 3600)
"#{hours}h ago"
diff < 518400 ->
diff < 518_400 ->
days = div(diff, 86400)
"#{days}d ago"
diff < 2419200 ->
weeks = div(diff, 604800)
diff < 2_419_200 ->
weeks = div(diff, 604_800)
"#{weeks}w ago"
diff < 28512000 ->
diff < 28_512_000 ->
months = Timex.diff(now, datetime, :months)
"#{months}mo ago"