show times on sessions in local time zone
This commit is contained in:
parent
0d4ab7fc14
commit
cc07e485b7
1 changed files with 12 additions and 1 deletions
|
|
@ -366,6 +366,17 @@ defmodule ToweropsWeb.UserSettingsLive do
|
|||
session.user_token_id == current_token_id
|
||||
end
|
||||
|
||||
defp format_timestamp_in_timezone(datetime, timezone) do
|
||||
case DateTime.shift_zone(datetime, timezone) do
|
||||
{:ok, shifted} ->
|
||||
Calendar.strftime(shifted, "%b %d, %Y %I:%M %p %Z")
|
||||
|
||||
{:error, _} ->
|
||||
# Fallback to UTC if timezone conversion fails
|
||||
Calendar.strftime(datetime, "%b %d, %Y %I:%M %p UTC")
|
||||
end
|
||||
end
|
||||
|
||||
defp format_browser_info(session) do
|
||||
case {session.browser_name, session.browser_version, session.os_name} do
|
||||
{nil, _, _} -> session.device_name || "Unknown Browser"
|
||||
|
|
@ -1268,7 +1279,7 @@ defmodule ToweropsWeb.UserSettingsLive do
|
|||
<%= for attempt <- @login_history do %>
|
||||
<tr>
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm text-gray-900 dark:text-white sm:pl-6">
|
||||
{Calendar.strftime(attempt.inserted_at, "%b %d, %Y %I:%M %p")}
|
||||
{format_timestamp_in_timezone(attempt.inserted_at, @timezone)}
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm">
|
||||
<%= if attempt.success do %>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue