### Basic Rule Generation Source: https://github.com/omerlo-technologies/ex_cycle/blob/main/README.md A quick-start example of creating a cycle and adding daily rules with specified hours. ```elixir ExCycle.new() |> ExCycle.add_rule(:daily, hours: [20, 10]) |> ExCycle.add_rule(:daily, interval: 2, hours: [15]) # Generates every day at 10:00 and 20:00 and every 2 days at 15:00 ``` -------------------------------- ### Generate Occurrences with ExCycle Source: https://github.com/omerlo-technologies/ex_cycle/blob/main/README.md Demonstrates how to create a new ExCycle instance, add daily rules with specific intervals and hours, and then generate occurrences starting from a given date. It shows how to take a specified number of occurrences. ```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]] ``` -------------------------------- ### Rule Generation with Duration Source: https://github.com/omerlo-technologies/ex_cycle/blob/main/README.md Shows how to add a daily rule with a specified hour and a duration, creating a time span. This example uses the `Duration` struct. ```elixir ExCycle.new() |> ExCycle.add_rule(:daily, hours: [10], duration: %Duration{hour: 2}) ``` -------------------------------- ### Stringify ExCycle Rule Source: https://github.com/omerlo-technologies/ex_cycle/blob/main/README.md Provides an example of how to stringify an `ExCycle.Rule` using a custom stringify function. This function formats rule components into a human-readable string. ```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(" ") # "daily at 10:00, 10:30" ``` -------------------------------- ### Rule Generation with Timezone Source: https://github.com/omerlo-technologies/ex_cycle/blob/main/README.md Demonstrates adding a daily rule with specific hours and a timezone, showing how to generate datetimes in a particular timezone. ```elixir ExCycle.new() |> ExCycle.add_rule(:daily, hours: [20, 10], timezone: "America/Montreal") # Generates every day at 10:00 and 20:00 with timezone America/Montreal ``` -------------------------------- ### Add ExCycle Dependency Source: https://github.com/omerlo-technologies/ex_cycle/blob/main/README.md Shows how to add the ExCycle library as a dependency in a Mix project by updating the `mix.exs` file. ```elixir def deps do [ {:ex_cycle, "~> 0.1.0"} ] end ``` -------------------------------- ### Configure Time Zone Database Source: https://github.com/omerlo-technologies/ex_cycle/blob/main/README.md Illustrates how to configure ExCycle to use a specific time zone database, such as Tzdata, either through Mix configuration or by directly calling a function. ```elixir config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase ``` ```elixir Calendar.put_time_zone_database(Tzdata.TimeZoneDatabase) ``` -------------------------------- ### Rule Generation with Duration and Timezone Source: https://github.com/omerlo-technologies/ex_cycle/blob/main/README.md Combines duration and timezone to generate time spans with Daylight Saving Time (DST) support, creating occurrences from a specific hour to two hours later in the specified timezone. ```elixir ExCycle.new() |> ExCycle.add_rule(:daily, hours: [10], duration: %Duration{hour: 2}, timezone: "America/Montreal") # Generates every day from 10:00 to 12:00 with timezone America/Montreal ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.