### ExCycle Installation Source: https://hexdocs.pm/ex_cycle/readme Shows how to add the ExCycle library as a dependency in a Mix project's `mix.exs` file. ```elixir def deps do [ {:ex_cycle, "~> 0.1.0"} ] end ``` -------------------------------- ### ExCycle Installation Source: https://hexdocs.pm/ex_cycle/index Provides the necessary configuration to add the ExCycle library as a dependency in an Elixir project's `mix.exs` file. ```elixir def deps do [ {:ex_cycle, "~> 0.1.0"} ] end ``` -------------------------------- ### ExCycle.Span API Reference Source: https://hexdocs.pm/ex_cycle/readme API documentation for the ExCycle.Span module, detailing how to create new spans with a start time and duration. ```APIDOC ExCycle.Span: new(from, duration) Creates a new span. Parameters: from: The start time of the span. duration: The duration of the span. Returns: A new span. ``` -------------------------------- ### ExCycle.Span API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle.Validations API documentation for the ExCycle.Span module, including its function for creating a new span with a start time and duration. ```APIDOC ExCycle.Span: new(from, duration) Creates a new span. Parameters: from: The start time of the span. duration: The duration of the span. Returns: A new span. ``` -------------------------------- ### ExCycle.Rule API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle.Validations API documentation for the ExCycle.Rule module, detailing functions for initializing, creating, and getting the next occurrence of a rule. ```APIDOC ExCycle.Rule: init(rule, from, opts \\ []) Initializes a rule. Parameters: rule: The rule to initialize. from: The starting point. opts: Optional arguments. new(frequency, opts \\ []) Creates a new rule. Parameters: frequency: The frequency of the rule. opts: Optional arguments. Returns: A new rule. next(rule) Gets the next occurrence of a rule. Parameters: rule: The rule to get the next occurrence for. Returns: The next occurrence. ``` -------------------------------- ### ExCycle Basic Usage Source: https://hexdocs.pm/ex_cycle/index Demonstrates the basic usage of the ExCycle library to generate a sequence of datetimes based on added recurrence rules. It shows how to initialize ExCycle, add daily rules with specific intervals and hours, and then retrieve a limited number of occurrences starting from a given date. ```iex iex> ExCycle.new() |>ExCycle.add_rule(:daily,interval:2,hours:[20,10]) |>ExCycle.add_rule(:daily,interval:1,hours:[15]) |>ExCycle.occurrences(~D[2024-02-29]) |>Enum.take(5) [~N[2024-02-29 10:00:00],~N[2024-02-29 15:00:00],~N[2024-02-29 20:00:00],~N[2024-03-01 15:00:00],~N[2024-03-02 10:00:00]] ``` -------------------------------- ### ExCycle Basic Usage Source: https://hexdocs.pm/ex_cycle/readme Demonstrates the basic usage of ExCycle to create a schedule, add daily recurrence rules with different intervals and hours, and retrieve the first five occurrences starting from a specific date. ```elixir iex> ExCycle.new() |> ExCycle.add_rule(:daily, interval: 2, hours: [20, 10]) |> ExCycle.add_rule(:daily, interval: 1, hours: [15]) |> ExCycle.occurrences(~D[2024-02-29]) |> Enum.take(5) [~N[2024-02-29 10:00:00], ~N[2024-02-29 15:00:00], ~N[2024-02-29 20:00:00], ~N[2024-03-01 15:00:00], ~N[2024-03-02 10:00:00]] ``` -------------------------------- ### Add Rules with Duration and Timezone Source: https://hexdocs.pm/ex_cycle/index Combines duration and timezone options to create recurring events with precise start and end times, including DST considerations. ```elixir ExCycle.new()|>ExCycle.add_rule(:daily,hours:[10],duration:%Duration{hour:2},timezone:"America/Montreal") ``` -------------------------------- ### ExCycle State Management Functions Source: https://hexdocs.pm/ex_cycle/ExCycle.Validations Provides functions to update and manage the state of an ExCycle process, including setting the next execution time, result, and the starting day of the week. ```elixir ExCycle.State.set_next(state, datetime) ExCycle.State.set_result(state) ExCycle.State.set_week_starting_on(state, week_starting_on) ExCycle.State.update_next(datetime_state, fun) ``` -------------------------------- ### ExCycle.Span API Reference Source: https://hexdocs.pm/ex_cycle/Duration Defines and manages time spans within ExCycle. Includes a function to create new spans with a start time and duration. ```APIDOC ExCycle.Span: new(from, duration) Creates a new span. Parameters: from: The start time of the span. duration: The duration of the span. Returns: A new span. ``` -------------------------------- ### ExCycle State Management Functions Source: https://hexdocs.pm/ex_cycle/Duration Functions for managing the state of an ExCycle process. These include setting the next execution time, setting the result of a cycle, setting the starting day of the week, and updating the next execution time using a function. ```APIDOC ExCycle.State: set_next(state, datetime) Sets the next execution datetime for the state. set_result(state) Sets the result for the current state. set_week_starting_on(state, week_starting_on) Sets the day of the week on which the cycle should start. update_next(datetime_state, fun) Updates the next execution datetime using a provided function. ``` -------------------------------- ### ExCycle.State Functions Source: https://hexdocs.pm/ex_cycle/index Provides functions for managing the state of cyclical processes. These functions allow for resetting the state, setting the next execution datetime, updating the next execution time based on a function, and setting the result or the starting day of the week. ```elixir reset(state) set_next(state, datetime) set_result(state) set_week_starting_on(state, week_starting_on) update_next(datetime_state, fun) ``` -------------------------------- ### ExCycle State Management Functions Source: https://hexdocs.pm/ex_cycle/readme Provides functions to manage the state within the ExCycle library. These functions allow for resetting the state, setting the next execution time, setting the result, setting the week's starting day, and updating the next execution time based on a function. ```APIDOC ExCycle.State: reset(state) - Resets the given state. set_next(state, datetime) - Sets the next execution datetime for the state. - Parameters: - state: The current state. - datetime: The datetime to set as the next execution time. set_result(state) - Sets the result for the state. set_week_starting_on(state, week_starting_on) - Sets the day of the week on which the week starts. - Parameters: - state: The current state. - week_starting_on: The integer representing the start day of the week (e.g., 1 for Monday). update_next(datetime_state, fun) - Updates the next execution datetime based on a provided function. - Parameters: - datetime_state: The current state containing the datetime. - fun: A function that takes the current datetime and returns a new datetime. ``` -------------------------------- ### ExCycle State Management Functions Source: https://hexdocs.pm/ex_cycle/ExCycle Provides functions to manage the state within the ExCycle library. These functions allow for resetting the state, setting the next execution time, setting the result, setting the week's starting day, and updating the next execution time based on a function. ```APIDOC ExCycle.State: reset(state) - Resets the given state. set_next(state, datetime) - Sets the next execution datetime for the state. - Parameters: - state: The current state. - datetime: The datetime to set as the next execution time. set_result(state) - Sets the result for the state. set_week_starting_on(state, week_starting_on) - Sets the day of the week on which the week starts. - Parameters: - state: The current state. - week_starting_on: The integer representing the start day of the week (e.g., 1 for Monday). update_next(datetime_state, fun) - Updates the next execution datetime based on a provided function. - Parameters: - datetime_state: The current state containing the datetime. - fun: A function that takes the current datetime and returns a new datetime. ``` -------------------------------- ### ExCycle State Management Functions Source: https://hexdocs.pm/ex_cycle/api-reference Provides functions to manage the state within the ExCycle library. These functions allow for resetting the state, setting the next execution time, setting the result, setting the week's starting day, and updating the next execution time based on a function. ```APIDOC ExCycle.State: reset(state) - Resets the given state. set_next(state, datetime) - Sets the next execution datetime for the state. - Parameters: - state: The current state. - datetime: The datetime to set as the next execution time. set_result(state) - Sets the result for the state. set_week_starting_on(state, week_starting_on) - Sets the day of the week on which the week starts. - Parameters: - state: The current state. - week_starting_on: The integer representing the start day of the week (e.g., 1 for Monday). update_next(datetime_state, fun) - Updates the next execution datetime based on a provided function. - Parameters: - datetime_state: The current state containing the datetime. - fun: A function that takes the current datetime and returns a new datetime. ``` -------------------------------- ### ExCycle.Span Type Source: https://hexdocs.pm/ex_cycle/ExCycle Defines the 't' type for ExCycle.Span, which represents a time span with a start and end time. ```elixir @type t() :: %ExCycle.Span{from: NaiveDateTime.t(), to: NaiveDateTime.t()} ``` -------------------------------- ### ExCycle.Rule API Reference Source: https://hexdocs.pm/ex_cycle/readme API documentation for the ExCycle.Rule module, covering initialization, creation of new rules, and calculating the next occurrence. ```APIDOC ExCycle.Rule: init(rule, from, opts \\ []) Initializes a rule. Parameters: rule: The rule to initialize. from: The starting point. opts: Optional arguments. new(frequency, opts \\ []) Creates a new rule. Parameters: frequency: The frequency of the rule. opts: Optional arguments. Returns: A new rule. next(rule) Calculates the next occurrence of a rule. Parameters: rule: The rule to calculate the next occurrence for. Returns: The next occurrence. ``` -------------------------------- ### ExCycle.Rule API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle API documentation for the ExCycle.Rule module, which handles the initialization, creation, and progression of rules within the ExCycle library. ```APIDOC ExCycle.Rule: init(rule, from, opts \\ []) Initializes a rule with a starting point and options. Parameters: rule: The rule to initialize. from: The starting point. opts: Optional arguments. new(frequency, opts \\ []) Creates a new rule. Parameters: frequency: The frequency of the rule. opts: Optional arguments. Returns: A new rule. next(rule) Calculates the next occurrence of a rule. Parameters: rule: The rule to advance. Returns: The next state of the rule. ``` -------------------------------- ### Create and Add Rules to a Cycle Source: https://hexdocs.pm/ex_cycle/index Demonstrates creating a new ExCycle and adding rules with specified frequencies and times. Supports options like `:interval` and `:hours`. ```elixir ExCycle.new()|>ExCycle.add_rule(:daily,hours:[20,10])|>ExCycle.add_rule(:daily,interval:2,hours:[15]) ``` -------------------------------- ### Create and Add Rules to a Cycle Source: https://hexdocs.pm/ex_cycle/readme Demonstrates creating a new ExCycle and adding rules with specified frequencies and hours. Supports multiple rules and intervals. ```elixir ExCycle.new()|>ExCycle.add_rule(:daily,hours:[20,10])|>ExCycle.add_rule(:daily,interval:2,hours:[15]) ``` -------------------------------- ### ExCycle Module Overview Source: https://hexdocs.pm/ex_cycle/api-reference Provides an overview of the ExCycle library's modules and their purposes. It details the functionality of Duration, ExCycle, ExCycle.Rule, ExCycle.Span, ExCycle.State, ExCycle.StringBuilder, ExCycle.Validations, and specific validation modules like DateExclusion, Days, DaysOfMonth, HourOfDay, Interval, Lock, and MinuteOfHour. ```elixir defmodule ExCycle do # Main module for recurring event generation. end defmodule ExCycle.Rule do # Represents an RRule following RFC 5455. end defmodule ExCycle.Span do # Generates datetimes with a Rule containing a Duration. # Requires 'from' and 'to' when a duration is specified. end defmodule ExCycle.State do # Represents the state of the next generated datetime. end defmodule ExCycle.StringBuilder do # Builds a stringified version of an ExCycle.Rule. end defmodule ExCycle.Validations do # Base module for validation strategies. end defmodule ExCycle.Validations.DateExclusion do # Excludes specific dates or datetimes from generated sequences. end defmodule ExCycle.Validations.Days do # Filters generated datetimes based on days of the week. end defmodule ExCycle.Validations.DaysOfMonth do # Filters generated datetimes based on the day number within a month. end defmodule ExCycle.Validations.HourOfDay do # Filters generated datetimes based on specific hours. end defmodule ExCycle.Validations.Interval do # Defines the base interval for RRule generation. end defmodule ExCycle.Validations.Lock do # Locks a specific item (e.g., :day) ensuring the generated datetime matches the restriction. end defmodule ExCycle.Validations.MinuteOfHour do # Filters generated datetimes based on specific minutes within an hour. end defmodule Duration do # Struct for representing durations, introduced in Elixir v1.17.0. end ``` -------------------------------- ### ExCycle.State API Reference Source: https://hexdocs.pm/ex_cycle/readme API documentation for the ExCycle.State module, covering state management, including applying durations and timezones, checking exhaustion, and ensuring validity. ```APIDOC ExCycle.State: apply_duration(state, duration) Applies a duration to a state. Parameters: state: The state to apply the duration to. duration: The duration to apply. apply_timezone(state, timezone) Applies a timezone to a state. Parameters: state: The state to apply the timezone to. timezone: The timezone to apply. check_exhaust(state, count) Checks if a state has been exhausted. Parameters: state: The state to check. count: The count to check against. ensure_valid(state) Ensures the validity of a state. Parameters: state: The state to validate. init(state, from) Initializes a state. Parameters: state: The state to initialize. from: The starting point. new(origin \\ NaiveDateTime.utc_now()) Creates a new state. Parameters: origin: The origin of the state (defaults to current UTC time). Returns: A new state. ``` -------------------------------- ### ExCycle.StringBuilder API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle.Validations Documentation for the ExCycle.StringBuilder module, focusing on its callback for string parameter processing and a function for traversing validations. ```APIDOC ExCycle.StringBuilder: string_params(any_validation) Callback for processing string parameters. Parameters: any_validation: The validation to process. traverse_validations(rule, msg_fun) Traverses validations within a rule. Parameters: rule: The rule to traverse. msg_fun: A function to apply to each validation message. ``` -------------------------------- ### ExCycle.StringBuilder API Reference Source: https://hexdocs.pm/ex_cycle/readme Documentation for the ExCycle.StringBuilder module, focusing on its types and functions for building string representations of validation rules. ```APIDOC ExCycle.StringBuilder: string_params(any_validation) Converts validation parameters to strings. Parameters: any_validation: The validation to process. Callbacks: string_params/1 traverse_validations(rule, msg_fun) Traverses validation rules and applies a message function. Parameters: rule: The rule to traverse. msg_fun: The function to apply to each validation message. ``` -------------------------------- ### ExCycle.Validations.Interval Source: https://hexdocs.pm/ex_cycle/index API documentation for the `ExCycle.Validations.Interval` module, specifically detailing the `new/2` function used for creating interval validations. ```APIDOC ExCycle.Validations.Interval: new(frequency, value \\ 1) Creates a new interval validation. Parameters: frequency: The frequency of the interval (e.g., :daily, :weekly). value: The interval value (defaults to 1). ``` -------------------------------- ### ExCycle API Reference Source: https://hexdocs.pm/ex_cycle/api-reference This section provides the API reference for the ExCycle library, detailing its modules, types, and functions for managing cycles and rules. ```APIDOC ExCycle: add_rule(cycle, frequency, opts \\ []) Adds a rule to a cycle. Parameters: cycle: The cycle to add the rule to. frequency: The frequency of the rule. opts: Options for the rule. new() Creates a new cycle. occurrences(cycle, from, opts \\ []) Calculates occurrences of a cycle. Parameters: cycle: The cycle to calculate occurrences for. from: The starting point for calculating occurrences. opts: Options for calculating occurrences. ExCycle.StringBuilder: string_params(any_validation) Converts validation to string parameters. Parameters: any_validation: The validation to convert. traverse_validations(rule, msg_fun) Traverses validations in a rule. Parameters: rule: The rule to traverse. msg_fun: A function to process messages. ExCycle.Rule: init(rule, from, opts \\ []) Initializes a rule. Parameters: rule: The rule to initialize. from: The starting point. opts: Options for initialization. new(frequency, opts \\ []) Creates a new rule. Parameters: frequency: The frequency of the rule. opts: Options for the rule. next(rule) Calculates the next occurrence of a rule. Parameters: rule: The rule to calculate the next occurrence for. ExCycle.Span: new(from, duration) Creates a new span. Parameters: from: The start of the span. duration: The duration of the span. ExCycle.State: apply_duration(state, duration) Applies a duration to a state. Parameters: state: The state to apply the duration to. duration: The duration to apply. apply_timezone(state, timezone) Applies a timezone to a state. Parameters: state: The state to apply the timezone to. timezone: The timezone to apply. check_exhaust(state, count) Checks if a state has been exhausted. Parameters: state: The state to check. count: The count to check against. ensure_valid(state) Ensures a state is valid. Parameters: state: The state to ensure validity for. init(state, from) Initializes a state. Parameters: state: The state to initialize. from: The starting point. new(origin \\ NaiveDateTime.utc_now()) Creates a new state. Parameters: origin: The origin of the state (defaults to current UTC time). ``` -------------------------------- ### ExCycle API Reference Source: https://hexdocs.pm/ex_cycle/index Provides core functionality for creating and managing cyclical rules and events. ```APIDOC ExCycle: add_rule(cycle, frequency, opts \\ []) Adds a rule to a cycle. Parameters: cycle: The cycle to add the rule to. frequency: The frequency of the rule. opts: Optional arguments. new() Creates a new cycle. occurrences(cycle, from, opts \\ []) Calculates occurrences of a cycle. Parameters: cycle: The cycle to calculate occurrences for. from: The starting point for calculating occurrences. opts: Optional arguments. ``` -------------------------------- ### ExCycle.State API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle.Validations API documentation for the ExCycle.State module, covering functions for managing the state of cyclical event processing, including applying durations, timezones, and checking exhaustion. ```APIDOC ExCycle.State: apply_duration(state, duration) Applies a duration to the state. Parameters: state: The current state. duration: The duration to apply. Returns: The updated state. apply_timezone(state, timezone) Applies a timezone to the state. Parameters: state: The current state. timezone: The timezone to apply. Returns: The updated state. check_exhaust(state, count) Checks if the state has been exhausted. Parameters: state: The current state. count: The count to check against. Returns: Boolean indicating exhaustion. ensure_valid(state) Ensures the state is valid. Parameters: state: The state to validate. init(state, from) Initializes the state. Parameters: state: The state to initialize. from: The starting point. Returns: The initialized state. new(origin \\ NaiveDateTime.utc_now()) Creates a new state. Parameters: origin: The origin datetime (defaults to current UTC time). Returns: A new state. reset(state) Resets the state. Parameters: state: The state to reset. Returns: The reset state. ``` -------------------------------- ### ExCycle API Reference Source: https://hexdocs.pm/ex_cycle/readme This section details the core functions and types within the ExCycle module, including adding rules, creating new cycles, and calculating occurrences. ```APIDOC ExCycle: add_rule(cycle, frequency, opts \\ []) Adds a rule to a cycle. Parameters: cycle: The cycle to add the rule to. frequency: The frequency of the rule. opts: Optional arguments. new() Creates a new ExCycle instance. Returns: A new ExCycle instance. occurrences(cycle, from, opts \\ []) Calculates occurrences of a cycle. Parameters: cycle: The cycle to calculate occurrences for. from: The starting point for calculation. opts: Optional arguments. Returns: A list of occurrences. ``` -------------------------------- ### ExCycle.StringBuilder API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle Documentation for the ExCycle.StringBuilder module, which provides functionality for building string representations of validation rules. ```APIDOC ExCycle.StringBuilder: string_params(any_validation) Converts validation parameters to a string. Parameters: any_validation: The validation to convert. traverse_validations(rule, msg_fun) Traverses validation rules and applies a message function. Parameters: rule: The rule to traverse. msg_fun: The function to apply to each validation message. ``` -------------------------------- ### Add Rules with Timezone Source: https://hexdocs.pm/ex_cycle/readme Shows how to add rules to an ExCycle while specifying a timezone, ensuring accurate scheduling across different regions. ```elixir ExCycle.new()|>ExCycle.add_rule(:daily,hours:[20,10],timezone:"America/Montreal") ``` -------------------------------- ### ExCycle.State API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle API reference for the ExCycle.State module, detailing functions for managing and manipulating the state of cyclical events, including applying durations and timezones. ```APIDOC ExCycle.State: apply_duration(state, duration) Applies a duration to a state. Parameters: state: The state to modify. duration: The duration to apply. Returns: The modified state. apply_timezone(state, timezone) Applies a timezone to a state. Parameters: state: The state to modify. timezone: The timezone to apply. Returns: The modified state. check_exhaust(state, count) Checks if a state has been exhausted based on a count. Parameters: state: The state to check. count: The count to compare against. Returns: Boolean indicating if the state is exhausted. ensure_valid(state) Ensures the validity of a state. Parameters: state: The state to validate. Returns: The validated state. init(state, from) Initializes a state with a starting point. Parameters: state: The state to initialize. from: The starting point. Returns: The initialized state. new(origin \\ NaiveDateTime.utc_now()) Creates a new state. Parameters: origin: The origin of the state (defaults to current UTC time). Returns: A new state. ``` -------------------------------- ### ExCycle Time Zone Configuration (Programmatic) Source: https://hexdocs.pm/ex_cycle/index Demonstrates how to programmatically set the timezone database for ExCycle using `Calendar.put_time_zone_database/1`. ```elixir Calendar.put_time_zone_database(Tzdata.TimeZoneDatabase) ``` -------------------------------- ### ExCycle Time Zone Configuration (Config) Source: https://hexdocs.pm/ex_cycle/readme Demonstrates how to configure ExCycle to use a specific time zone database, such as Tzdata, via the `config/config.exs` file. ```elixir config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase ``` -------------------------------- ### ExCycle Time Zone Configuration (Runtime) Source: https://hexdocs.pm/ex_cycle/readme Demonstrates how to configure ExCycle to use a specific time zone database, such as Tzdata, at runtime using `Calendar.put_time_zone_database/1`. ```elixir Calendar.put_time_zone_database(Tzdata.TimeZoneDatabase) ``` -------------------------------- ### Add Rules with Timezone Source: https://hexdocs.pm/ex_cycle/index Shows how to add rules to an ExCycle while specifying a timezone, ensuring accurate datetime generation with DST support. ```elixir ExCycle.new()|>ExCycle.add_rule(:daily,hours:[20,10],timezone:"America/Montreal") ``` -------------------------------- ### ExCycle.Validations.Lock Source: https://hexdocs.pm/ex_cycle/index API documentation for the `ExCycle.Validations.Lock` module, including its types and the `new/1` function for creating lock validations. ```APIDOC ExCycle.Validations.Lock: t(): Represents a lock validation. unit(): Represents the unit for a lock validation. new(unit) Creates a new lock validation. Parameters: unit: The unit for the lock validation. ``` -------------------------------- ### ExCycle.Rule API Reference Source: https://hexdocs.pm/ex_cycle/Duration Manages the internal state and logic for cyclical rules. Provides functions for initializing rules, creating new rules, and determining the next occurrence. ```APIDOC ExCycle.Rule: init(rule, from, opts \\ []) Initializes a rule with a starting point and options. Parameters: rule: The rule to initialize. from: The starting point. opts: Options for initialization. Returns: The initialized rule. new(frequency, opts \\ []) Creates a new rule. Parameters: frequency: The frequency of the rule. opts: Options for the new rule. Returns: A new rule. next(rule) Calculates the next occurrence of a rule. Parameters: rule: The rule to calculate the next occurrence for. Returns: The next occurrence. ``` -------------------------------- ### ExCycle.Validations.MinuteOfHour Source: https://hexdocs.pm/ex_cycle/index API documentation for the `ExCycle.Validations.MinuteOfHour` module, including its types and the `new/1` function for creating minute-of-hour validations. ```APIDOC ExCycle.Validations.MinuteOfHour: t(): Represents a minute-of-hour validation. new(minutes) Creates a new minute-of-hour validation. Parameters: minutes: A list of minutes within the hour. ``` -------------------------------- ### ExCycle.Span API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle Documentation for the ExCycle.Span module, which is used for defining and creating time spans within the ExCycle library. ```APIDOC ExCycle.Span: new(from, duration) Creates a new time span. Parameters: from: The start of the span. duration: The duration of the span. Returns: A new time span. ``` -------------------------------- ### ExCycle API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle.Validations This section details the core functions for managing cyclical events within the ExCycle library. It covers adding rules, creating new cycles, and calculating occurrences. ```APIDOC ExCycle: add_rule(cycle, frequency, opts \\ []) Adds a rule to a cycle. Parameters: cycle: The cycle to add the rule to. frequency: The frequency of the rule. opts: Optional arguments. new() Creates a new cycle. Returns: A new cycle. occurrences(cycle, from, opts \\ []) Calculates occurrences of a cycle. Parameters: cycle: The cycle to calculate occurrences for. from: The starting point for calculating occurrences. opts: Optional arguments. Returns: A list of occurrences. ``` -------------------------------- ### Add Rules with Duration and Timezone Source: https://hexdocs.pm/ex_cycle/readme Combines duration and timezone options to create recurring events with DST support, ensuring accurate span generation. ```elixir ExCycle.new()|>ExCycle.add_rule(:daily,hours:[10],duration:%Duration{hour:2},timezone:"America/Montreal") ``` -------------------------------- ### ExCycle Time Zone Configuration (tzdata) Source: https://hexdocs.pm/ex_cycle/index Shows how to configure ExCycle to use the `tzdata` library for timezone handling. This involves adding `tzdata` as a dependency and then setting the `time_zone_database` configuration in `config/config.exs` or programmatically. ```elixir config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase ``` -------------------------------- ### ExCycle.State API Reference Source: https://hexdocs.pm/ex_cycle/Duration Manages the state of a cycle, including applying durations and timezones, checking for exhaustion, and ensuring validity. Provides functions for initializing and resetting the state. ```APIDOC ExCycle.State: apply_duration(state, duration) Applies a duration to the current state. Parameters: state: The current state. duration: The duration to apply. Returns: The updated state. apply_timezone(state, timezone) Applies a timezone to the current state. Parameters: state: The current state. timezone: The timezone to apply. Returns: The updated state. check_exhaust(state, count) Checks if the state has been exhausted based on a count. Parameters: state: The current state. count: The count to check against. Returns: Boolean indicating if the state is exhausted. ensure_valid(state) Ensures the validity of the state. Parameters: state: The state to validate. Returns: The validated state. init(state, from) Initializes the state with a starting point. Parameters: state: The state to initialize. from: The starting point. Returns: The initialized state. new(origin \\ NaiveDateTime.utc_now()) Creates a new state. Parameters: origin: The origin for the state (defaults to current UTC time). Returns: A new state. reset(state) Resets the state. Parameters: state: The state to reset. Returns: The reset state. ``` -------------------------------- ### ExCycle.State API Reference Source: https://hexdocs.pm/ex_cycle/index Manages the state of cyclical event processing. ```APIDOC ExCycle.State: apply_duration(state, duration) Applies a duration to the current state. Parameters: state: The current state. duration: The duration to apply. apply_timezone(state, timezone) Applies a timezone to the current state. Parameters: state: The current state. timezone: The timezone to apply. check_exhaust(state, count) Checks if the state has been exhausted based on a count. Parameters: state: The current state. count: The count to check against. ensure_valid(state) Ensures the state is valid. Parameters: state: The state to validate. init(state, from) Initializes the state. Parameters: state: The initial state. from: The starting point. new(origin \\ NaiveDateTime.utc_now()) Creates a new state. Parameters: origin: The origin of the state (defaults to current UTC time). ``` -------------------------------- ### ExCycle.Duration Source: https://hexdocs.pm/ex_cycle/index API documentation for the `ExCycle.Duration` module, detailing its type definition. ```APIDOC ExCycle.Duration: t(): Represents a duration. ``` -------------------------------- ### ExCycle.Rule API Reference Source: https://hexdocs.pm/ex_cycle/index Manages the internal representation and logic of cyclical rules. ```APIDOC ExCycle.Rule: init(rule, from, opts \\ []) Initializes a rule. Parameters: rule: The rule to initialize. from: The starting point. opts: Optional arguments. new(frequency, opts \\ []) Creates a new rule. Parameters: frequency: The frequency of the rule. opts: Optional arguments. next(rule) Calculates the next occurrence of a rule. Parameters: rule: The rule to calculate the next occurrence for. ``` -------------------------------- ### ExCycle API Reference Source: https://hexdocs.pm/ex_cycle/Duration Provides core functionality for creating and managing cyclical rules and calculating occurrences. Includes functions for adding rules, creating new cycles, and determining future occurrences. ```APIDOC ExCycle: add_rule(cycle, frequency, opts \\ []) Adds a rule to a cycle. Parameters: cycle: The cycle to add the rule to. frequency: The frequency of the rule. opts: Options for the rule. new() Creates a new ExCycle. Returns: A new ExCycle. occurrences(cycle, from, opts \\ []) Calculates occurrences of a cycle. Parameters: cycle: The cycle to calculate occurrences for. from: The starting point for calculating occurrences. opts: Options for calculating occurrences. Returns: A list of occurrences. ``` -------------------------------- ### ExCycle.Validations.MinuteOfHour Functions Source: https://hexdocs.pm/ex_cycle/ExCycle Provides functions for creating and managing MinuteOfHour validations in ExCycle. ```elixir ExCycle.Validations.MinuteOfHour.new/1 ``` -------------------------------- ### ExCycle API Reference Source: https://hexdocs.pm/ex_cycle/ExCycle This section details the functions available in the ExCycle module for managing cyclical rules and occurrences. It includes functions for adding rules, creating new cycles, and calculating occurrences. ```APIDOC ExCycle: add_rule(cycle, frequency, opts \\ []) Adds a rule to a cycle. Parameters: cycle: The cycle to add the rule to. frequency: The frequency of the rule. opts: Optional arguments. new() Creates a new cycle. Returns: A new cycle. occurrences(cycle, from, opts \\ []) Calculates occurrences of a cycle. Parameters: cycle: The cycle to calculate occurrences for. from: The starting point for calculating occurrences. opts: Optional arguments. Returns: A list of occurrences. ``` -------------------------------- ### ExCycle.Validations.Interval Functions Source: https://hexdocs.pm/ex_cycle/ExCycle Provides functions for creating and managing intervals within the ExCycle validation system. ```elixir ExCycle.Validations.Interval.new/2 ``` -------------------------------- ### ExCycle.Validations API Source: https://hexdocs.pm/ex_cycle/index Defines validation strategies for cyclical processes. This includes a general `any_validation` type and callback functions `next/2` and `valid?/2` for applying these validations. ```APIDOC ExCycle.Validations: any_validation(): Type for any validation. next(t, any_validation): Callback to advance validation state. valid?(t, any_validation): Callback to check if validation is met. ``` -------------------------------- ### ExCycle.StringBuilder API Reference Source: https://hexdocs.pm/ex_cycle/index Handles string manipulation and validation within ExCycle rules. ```APIDOC ExCycle.StringBuilder: string_params(any_validation) Processes string parameters for validation. Parameters: any_validation: The validation to process. traverse_validations(rule, msg_fun) Traverses validations within a rule. Parameters: rule: The rule to traverse. msg_fun: A function to process messages. ``` -------------------------------- ### ExCycle Validations Callbacks and Types Source: https://hexdocs.pm/ex_cycle/api-reference Defines callbacks and types for creating custom validations within ExCycle. It includes a general `any_validation` type and callbacks for `next` and `valid?` operations. ```APIDOC ExCycle.Validations: Types: t: any_validation() - Represents any type of validation. Callbacks: next(t, any_validation) - Calculates the next valid occurrence based on the validation rules. - Parameters: - t: The validation struct. - any_validation: The current validation configuration. - Returns: The next occurrence. valid?(t, any_validation) - Checks if a given datetime is valid according to the validation rules. - Parameters: - t: The validation struct. - any_validation: The current validation configuration. - Returns: Boolean indicating validity. ``` -------------------------------- ### ExCycle.StringBuilder API Reference Source: https://hexdocs.pm/ex_cycle/Duration Handles the string representation of validation rules within ExCycle. Includes a callback for stringifying parameters. ```APIDOC ExCycle.StringBuilder: string_params(any_validation) Converts validation parameters to a string. Parameters: any_validation: The validation parameters. Returns: A string representation of the parameters. traverse_validations(rule, msg_fun) Traverses validation rules and applies a message function. Parameters: rule: The rule to traverse. msg_fun: The function to apply to each validation message. Returns: The result of applying the message function. ``` -------------------------------- ### ExCycle.Span API Reference Source: https://hexdocs.pm/ex_cycle/index Defines and manages time spans within ExCycle. ```APIDOC ExCycle.Span: new(from, duration) Creates a new time span. Parameters: from: The start of the span. duration: The duration of the span. ``` -------------------------------- ### ExCycle Validations Callbacks and Types Source: https://hexdocs.pm/ex_cycle/ExCycle Defines callbacks and types for creating custom validations within ExCycle. It includes a general `any_validation` type and callbacks for `next` and `valid?` operations. ```APIDOC ExCycle.Validations: Types: t: any_validation() - Represents any type of validation. Callbacks: next(t, any_validation) - Calculates the next valid occurrence based on the validation rules. - Parameters: - t: The validation struct. - any_validation: The current validation configuration. - Returns: The next occurrence. valid?(t, any_validation) - Checks if a given datetime is valid according to the validation rules. - Parameters: - t: The validation struct. - any_validation: The current validation configuration. - Returns: Boolean indicating validity. ``` -------------------------------- ### ExCycle Validations Callbacks and Types Source: https://hexdocs.pm/ex_cycle/readme Defines callbacks and types for creating custom validations within ExCycle. It includes a general `any_validation` type and callbacks for `next` and `valid?` operations. ```APIDOC ExCycle.Validations: Types: t: any_validation() - Represents any type of validation. Callbacks: next(t, any_validation) - Calculates the next valid occurrence based on the validation rules. - Parameters: - t: The validation struct. - any_validation: The current validation configuration. - Returns: The next occurrence. valid?(t, any_validation) - Checks if a given datetime is valid according to the validation rules. - Parameters: - t: The validation struct. - any_validation: The current validation configuration. - Returns: Boolean indicating validity. ``` -------------------------------- ### ExCycle.Validations.MinuteOfHour.new/1 Source: https://hexdocs.pm/ex_cycle/readme Creates a new MinuteOfHour validation. This function is part of the ExCycle.Validations.MinuteOfHour module. ```APIDOC ExCycle.Validations.MinuteOfHour.new(minutes) * minutes: The minutes for the validation. ``` -------------------------------- ### Add Rules with Duration Source: https://hexdocs.pm/ex_cycle/readme Illustrates adding rules with a duration, using Elixir's `Duration` struct to define the span of the recurring event. ```elixir ExCycle.new()|>ExCycle.add_rule(:daily,hours:[10],duration:%Duration{hour:2}) ``` -------------------------------- ### Add Rules with Duration Source: https://hexdocs.pm/ex_cycle/index Illustrates adding rules with a duration, using Elixir's `Duration` struct to define the span of the recurring event. ```elixir ExCycle.new()|>ExCycle.add_rule(:daily,hours:[10],duration:%Duration{hour:2}) ``` -------------------------------- ### ExCycle.Span Functions Source: https://hexdocs.pm/ex_cycle/ExCycle Provides functions for creating and managing ExCycle.Span, used for generating datetimes within a specified duration. ```elixir @spec new(NaiveDateTime.t(), Duration.t()) :: t() ``` -------------------------------- ### ExCycle.Validations.Lock Functions Source: https://hexdocs.pm/ex_cycle/ExCycle Provides functions for creating and managing locks within the ExCycle validation system. ```elixir ExCycle.Validations.Lock.new/1 ``` -------------------------------- ### Duration.t/0 Source: https://hexdocs.pm/ex_cycle/readme Defines the main type `t/0` for the Duration module. ```APIDOC Duration.t() The main type for Duration. ``` -------------------------------- ### ExCycle.Validations.MinuteOfHour Types Source: https://hexdocs.pm/ex_cycle/readme Defines the types for the ExCycle.Validations.MinuteOfHour module, including the main type `t/0`. ```APIDOC ExCycle.Validations.MinuteOfHour.t() The main type for MinuteOfHour validation. ``` -------------------------------- ### ExCycle Interval Validation Functions Source: https://hexdocs.pm/ex_cycle/api-reference Provides functions for validating intervals. The `new/2` function is used to create a new interval with a specified frequency and value. ```APIDOC ExCycle.Validations.Interval: new(frequency, value \\ 1) Creates a new interval. Parameters: frequency: The frequency of the interval. value: The value of the interval (defaults to 1). ``` -------------------------------- ### Stringify ExCycle Rule Source: https://hexdocs.pm/ex_cycle/index Provides a function to stringify an ExCycle rule, converting its components into a human-readable string format. This function is experimental and may have breaking changes. ```elixir stringify = fn(field, msg_opts) -> msg = Enum.map_join(msg_opts, ", ", fn {msg, opts} -> Regex.replace(~r"%{(\w+)}", msg, fn _, key -> opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() end) end) case field do :interval -> msg :times -> "at " <> msg :minutes -> "every hours at minutes " <> msg :days_of_month -> "on the " <> msg :days -> "on " <> msg end end ExCycle.Rule.new(:weekly, days: [:monday], hours: [10], minutes: [30]) |> ExCycle.StringBuilder.traverse_validations(stringify) |> Enum.join(" ") ``` -------------------------------- ### ExCycle Validations - Callbacks Source: https://hexdocs.pm/ex_cycle/Duration Callbacks for defining custom validation logic within ExCycle. These include a generic `any_validation` type and functions to check the validity of a given state. ```APIDOC ExCycle.Validations: any_validation() Represents any type of validation. next(t, any_validation) Applies a validation to the next state. valid?(t, any_validation) Checks if the current state is valid according to the provided validation. ``` -------------------------------- ### ExCycle.Validations.Days Source: https://hexdocs.pm/ex_cycle/Duration Defines validation strategies based on specific days of the week or patterns. It includes types for individual days, weeks, and a function to create new day-based validation rules. ```APIDOC ExCycle.Validations.Days: day() Type representing a single day of the week. week() Type representing a week pattern. t() Type for Days validation. new(days) Creates a new Days validation rule. Parameters: days: A list of days or week patterns to include. ``` -------------------------------- ### ExCycle.Validations.Days API Source: https://hexdocs.pm/ex_cycle/index A validation strategy to specify allowed days of the week for a cycle. It defines types for `day`, `week`, and `t`, and provides a `new/1` function to create a `Days` validation. ```APIDOC ExCycle.Validations.Days: day(): Type for a single day. week(): Type for a week. t(): Struct for Days validation. new(days): Creates a new Days validation with the specified days. ```