file server started in supervisor tree

This commit is contained in:
Owen
2024-12-15 22:48:47 +01:00
parent 81c95c28b2
commit 1b1fa19fff
8 changed files with 30 additions and 9 deletions
+19
View File
@@ -0,0 +1,19 @@
# https://rosettacode.org/wiki/Convert_seconds_to_compound_duration
defmodule PlantIdDiscordBot.Utils.Duration do
@minute 60
@hour @minute * 60
@day @hour * 24
@week @day * 7
@divisor [@week, @day, @hour, @minute, 1]
def sec_to_str(sec) do
{_, [s, m, h, d, w]} =
Enum.reduce(@divisor, {sec, []}, fn divisor, {n, acc} ->
{rem(n, divisor), [div(n, divisor) | acc]}
end)
["#{w}w", "#{d}d", "#{h}h", "#{m}m", "#{s}s"]
|> Enum.reject(fn str -> String.starts_with?(str, "0") end)
|> Enum.join(" ")
end
end