Claude set up a '/labels' endpoint
This commit is contained in:
16
lib/labelmaker_web/controllers/labels_html.ex
Normal file
16
lib/labelmaker_web/controllers/labels_html.ex
Normal file
@@ -0,0 +1,16 @@
|
||||
defmodule LabelmakerWeb.LabelsHTML do
|
||||
use LabelmakerWeb, :html
|
||||
|
||||
embed_templates "labels_html/*"
|
||||
|
||||
def format_size(bytes) when bytes < 1024, do: "#{bytes} B"
|
||||
def format_size(bytes) when bytes < 1024 * 1024, do: "#{Float.round(bytes / 1024, 1)} KB"
|
||||
def format_size(bytes), do: "#{Float.round(bytes / (1024 * 1024), 1)} MB"
|
||||
|
||||
def format_datetime({{year, month, day}, {hour, minute, second}}) do
|
||||
"#{year}-#{pad(month)}-#{pad(day)} #{pad(hour)}:#{pad(minute)}:#{pad(second)}"
|
||||
end
|
||||
|
||||
defp pad(num) when num < 10, do: "0#{num}"
|
||||
defp pad(num), do: "#{num}"
|
||||
end
|
||||
Reference in New Issue
Block a user