summaryrefslogtreecommitdiff
path: root/lib/lsg_irc
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2022-12-11 01:04:58 +0000
committerJordan Bracco <href@random.sh>2022-12-11 02:03:36 +0000
commit98be237aba84c9e64391b2f6cd5bc4e686709905 (patch)
tree707d92d7b52d65baf801994e1a44927703fe63b3 /lib/lsg_irc
parentchore: fix git ignore for config/releases.exs (diff)
fix: alcoolog: time fixes
Diffstat (limited to 'lib/lsg_irc')
-rw-r--r--lib/lsg_irc/alcolog_plugin.ex7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/lsg_irc/alcolog_plugin.ex b/lib/lsg_irc/alcolog_plugin.ex
index 46c43f4..f61b237 100644
--- a/lib/lsg_irc/alcolog_plugin.ex
+++ b/lib/lsg_irc/alcolog_plugin.ex
@@ -492,9 +492,9 @@ defmodule LSG.IRC.AlcoologPlugin do
@spec since() :: %{IRC.Account.id() => DateTime.t()}
@doc "Returns the last time the user was at 0 g/l"
def since() do
- :ets.foldr(fn({{acct, timestamp}, _vol, current, _cl, _deg, _name, _comment, _m}, acc) ->
+ :ets.foldr(fn({{acct, timestamp_or_date}, _vol, current, _cl, _deg, _name, _comment, _m}, acc) ->
if !Map.get(acc, acct) && current == 0 do
- date = DateTime.from_unix!(timestamp, :millisecond)
+ date = Util.to_date_time(timestamp_or_date)
Map.put(acc, acct, date)
else
acc
@@ -1198,11 +1198,12 @@ defmodule LSG.IRC.AlcoologPlugin do
date = DateTime.from_unix!(date, :millisecond)
|> Timex.Timezone.convert("Europe/Paris")
else
- date
+ Util.to_naive_date_time(date)
end
now = DateTime.utc_now()
|> Timex.Timezone.convert("Europe/Paris")
{:ok, detail} = Timex.Format.DateTime.Formatters.Default.lformat(date, "({h24}:{m})", "fr")
+
mins_since = round(DateTime.diff(now, date)/60.0)
if ago = format_minute_duration(mins_since) do
word = if mins_since > 0 do