Skip to content

Commit

Permalink
missed files
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Dec 17, 2024
1 parent 4e2f369 commit 8276292
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions assets/js/timeUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const getRelativeTimeString = (date, language = 'en') => {
console.log(language)
const rtf = new Intl.RelativeTimeFormat(language, { numeric: 'auto' });
const now = new Date();
const diffInMs = date - now;
const diffInDays = Math.round(diffInMs / (1000 * 60 * 60 * 24));
const diffInHours = Math.round(diffInMs / (1000 * 60 * 60));
const diffInMinutes = Math.round(diffInMs / (1000 * 60));

if (Math.abs(diffInMinutes) < 60) return rtf.format(diffInMinutes, 'minute');
if (Math.abs(diffInHours) < 24) return rtf.format(diffInHours, 'hour');
return rtf.format(diffInDays, 'day');
};
19 changes: 19 additions & 0 deletions lib/mindwendel_web/templates/layout/app_static.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<main role="main" class="container" id="main-container">
<%= if Phoenix.Flash.get(@flash, :info) do %>
<p class="alert alert-info" role="alert" phx-click="lv:clear-flash" phx-value-key="info">
{Phoenix.Flash.get(@flash, :info)}
</p>
<% end %>
<%= if Phoenix.Flash.get(@flash, :error) do %>
<p
id="alert-danger"
class="alert alert-danger"
phx-hook="RemoveMissingBrainstorming"
role="alert"
data-brainstorming-id={Phoenix.Flash.get(@flash, :missing_brainstorming_id)}
>
{Phoenix.Flash.get(@flash, :error)}
</p>
<% end %>
{@inner_content}
</main>

0 comments on commit 8276292

Please sign in to comment.