View Source Mobilizon.Service.DateTime (Mobilizon v5.0.0-beta.1)

Module to represent a datetime in a given locale

Summary

Functions

Link to this function

calculate_first_day_of_week(date, locale \\ "en")

View Source
@spec calculate_first_day_of_week(Date.t(), String.t()) :: Date.t()
Link to this function

calculate_next_day_notification(day, options \\ [])

View Source
@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 datetime
  • notification_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"
Link to this function

calculate_next_week_notification(begins_on, options \\ [])

View Source
@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 datetime
  • notification_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".
Link to this function

datetime_relative(datetime, locale \\ "en")

View Source
@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()
Link to this function

datetime_to_string(datetime, locale \\ "en", format \\ :medium)

View Source
@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()
Link to this function

datetime_tz_convert(datetime, timezone)

View Source
@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()
Link to this function

is_between_hours?(options \\ [])

View Source
@spec is_between_hours?(Keyword.t()) :: boolean()
Link to this function

is_between_hours_on_first_day?(options)

View Source
@spec is_between_hours_on_first_day?(Keyword.t()) :: boolean()
Link to this function

next_first_day_of_week(datetime, options)

View Source
@spec next_first_day_of_week(DateTime.t(), Keyword.t()) :: Date.t() | nil
@spec same_day?(DateTime.t(), DateTime.t()) :: boolean()