diff options
Diffstat (limited to 'lib/lsg_irc')
-rw-r--r-- | lib/lsg_irc/alcolog_plugin.ex | 7 |
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 |