View Source Mobilizon.Service.DateTime (Mobilizon v5.0.0-beta.1)
Module to represent a datetime in a given locale
Summary
Functions
Calculate the time when a notification should be sent, based on a daily schedule
Calculate the time when a notification should be sent, based on a weekly schedule
Functions
@spec calculate_next_day_notification(Date.t(), Keyword.t()) :: DateTime.t()
Calculate the time when a notification should be sent, based on a daily schedule
Parameters
compare_to
When to compare to. Defaults to the current datetimenotification_time
The time when the notification is being sent. Defaults to~T[08:00:00]
timezone
The user's timezone. Needed to convert the time in the user's local timezone. Defaults to"Etc/UTC"
@spec calculate_next_week_notification(DateTime.t(), Keyword.t()) :: DateTime.t() | nil
Calculate the time when a notification should be sent, based on a weekly schedule
Parameters
compare_to
When to compare to. Defaults to the current datetimenotification_time
The time when the notification is being sent. Defaults to~T[08:00:00]
timezone
The user's timezone. Needed to convert the time in the user's local timezone. Defaults to"Etc/UTC"
locale
The user's locale. Allows to get the first day of the week to send the notification on the beginning of the week. Defaults to"en"
.
@spec datetime_relative(DateTime.t(), String.t()) :: String.t()
Link to this function
datetime_to_date_string(datetime, locale \\ "en", format \\ :short)
View Source@spec datetime_to_date_string(DateTime.t(), String.t(), to_string_format()) :: String.t()
@spec datetime_to_string(DateTime.t(), String.t(), to_string_format()) :: String.t()
Link to this function
datetime_to_time_string(datetime, locale \\ "en", format \\ :short)
View Source@spec datetime_to_time_string(DateTime.t(), String.t(), to_string_format()) :: String.t()
@spec datetime_tz_convert(DateTime.t(), String.t() | nil) :: DateTime.t()
Link to this function
delay_ok_since_last_notification_sent?(last_notification_sent, delay \\ 3600)
View Source@spec delay_ok_since_last_notification_sent?(DateTime.t(), pos_integer()) :: boolean()
@spec next_first_day_of_week(DateTime.t(), Keyword.t()) :: Date.t() | nil
@spec same_day?(DateTime.t(), DateTime.t()) :: boolean()