From 9ddcd6dff69f1018b05d20a6a60cbabbe433cfa5 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 29 Mar 2022 10:38:50 +0200 Subject: [PATCH] Make sure timezone as an UTC fallback in case it's nil Signed-off-by: Thomas Citharel --- lib/service/date_time/date_time.ex | 2 +- lib/service/workers/notification.ex | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/service/date_time/date_time.ex b/lib/service/date_time/date_time.ex index d1aec54f..9c2a8278 100644 --- a/lib/service/date_time/date_time.ex +++ b/lib/service/date_time/date_time.ex @@ -182,7 +182,7 @@ defmodule Mobilizon.Service.DateTime do compare_to_day = Keyword.get(options, :compare_to_day, Date.utc_today()) compare_to = Keyword.get(options, :compare_to_datetime, DateTime.utc_now()) start_time = Keyword.get(options, :start_time, @start_time) - timezone = Keyword.get(options, :timezone, "Etc/UTC") + timezone = Keyword.get(options, :timezone, "Etc/UTC") || "Etc/UTC" end_time = Keyword.get(options, :end_time, @end_time) DateTime.compare(compare_to, DateTime.new!(compare_to_day, start_time, timezone)) in [ diff --git a/lib/service/workers/notification.ex b/lib/service/workers/notification.ex index 46d3310e..3282169d 100644 --- a/lib/service/workers/notification.ex +++ b/lib/service/workers/notification.ex @@ -46,7 +46,7 @@ defmodule Mobilizon.Service.Workers.Notification do }) do with %User{locale: locale, settings: %Setting{timezone: timezone, notification_on_day: true}} = user <- Users.get_user_with_settings!(user_id), - {start, tomorrow} <- calculate_start_end(1, timezone), + {start, tomorrow} <- calculate_start_end(1, timezone || "Etc/UTC"), %Page{ elements: participations, total: total @@ -80,7 +80,7 @@ defmodule Mobilizon.Service.Workers.Notification do locale: locale, settings: %Setting{timezone: timezone, notification_each_week: true} } = user <- Users.get_user_with_settings!(user_id), - {start, end_week} <- calculate_start_end(7, timezone), + {start, end_week} <- calculate_start_end(7, timezone || "Etc/UTC"), %Page{ elements: participations, total: total