Show full version timestamp with friendly date on agents page
This commit is contained in:
parent
94405f0716
commit
fce1a8b229
1 changed files with 14 additions and 2 deletions
|
|
@ -121,11 +121,23 @@ defmodule ToweropsWeb.AgentLive.Helpers do
|
|||
Formats agent version for display.
|
||||
|
||||
Handles both legacy semver ("1.2.3") and RFC 3339 timestamp ("2026-02-09T14:30:00Z") formats.
|
||||
Timestamps are displayed as date only (e.g., "2026-02-09").
|
||||
Timestamps show the full value with a human-readable date, e.g. "2026-02-09T14:30:00Z (Feb 9, 2026)".
|
||||
"""
|
||||
def format_agent_version(version) when is_binary(version) do
|
||||
if String.match?(version, ~r/^\d{4}-\d{2}-\d{2}T/) do
|
||||
String.slice(version, 0, 10)
|
||||
date = String.slice(version, 0, 10)
|
||||
|
||||
friendly =
|
||||
case Date.from_iso8601(date) do
|
||||
{:ok, d} ->
|
||||
month = Enum.at(~w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec), d.month - 1)
|
||||
" (#{month} #{d.day}, #{d.year})"
|
||||
|
||||
_ ->
|
||||
""
|
||||
end
|
||||
|
||||
"#{version}#{friendly}"
|
||||
else
|
||||
"v#{version}"
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue