Add models and migrations
This commit is contained in:
parent
182523d36d
commit
9e542bc790
33 changed files with 597 additions and 125 deletions
|
@ -38,4 +38,42 @@ defmodule NullaWeb.UserHTML do
|
|||
|
||||
"#{formatted} (#{relative})"
|
||||
end
|
||||
|
||||
def format_note_datetime(datetime) do
|
||||
Timex.format!(datetime, "{0D} {Mfull} {YYYY}, {h24}:{m}", :strftime)
|
||||
end
|
||||
|
||||
def format_note_datetime_diff(datetime) do
|
||||
now = Timex.now()
|
||||
diff = Timex.diff(now, datetime, :seconds)
|
||||
|
||||
cond do
|
||||
diff < 60 ->
|
||||
"now"
|
||||
|
||||
diff < 3600 ->
|
||||
minutes = div(diff, 60)
|
||||
"#{minutes}m ago"
|
||||
|
||||
diff < 86400 ->
|
||||
hours = div(diff, 3600)
|
||||
"#{hours}h ago"
|
||||
|
||||
diff < 518400 ->
|
||||
days = div(diff, 86400)
|
||||
"#{days}d ago"
|
||||
|
||||
diff < 2419200 ->
|
||||
weeks = div(diff, 604800)
|
||||
"#{weeks}w ago"
|
||||
|
||||
diff < 28512000 ->
|
||||
months = Timex.diff(now, datetime, :months)
|
||||
"#{months}mo ago"
|
||||
|
||||
true ->
|
||||
years = Timex.diff(now, datetime, :years)
|
||||
"#{years}y ago"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue