Matsa59

Matsa59

ExCycle - Manage recurrent date(times) with timezone and daylight saving

Hello folks,

I release a couple of months ago ex_cycle for managing recurrent date(times) in elixir. I know there is cocktail but we decided to create our own lib since Cocktail doesn’t handle well timezoned datetimes. I tried to fix it on Cocktail but the problem seems to be harder that just updating a function.

So here we are : ex_cycle | Hex

Disclaimer : cocktail have some features that we don’t (like working with RRule as string).

But after a couple of months using it we could stay the lib is almost prod ready (we miss some important feature to be prod ready IMO, like display a cycle as string like “Every day at 10AM”).

Here an basic example

iex> ExCycle.new() 
...> |> ExCycle.add_rule(:monthly,
...>    days_of_month: [-1, 1, 10, 28], 
...>    hours: [10, 20], 
...>    timezone: "America/Montreal"
...> )
...> |> ExCycle.occurrences(~N[2025-02-01 00:00:00]) 
...> |> Enum.take(14)

[#DateTime<2025-02-01 10:00:00-05:00 EST America/Montreal>,
 #DateTime<2025-02-01 20:00:00-05:00 EST America/Montreal>,
 #DateTime<2025-02-10 10:00:00-05:00 EST America/Montreal>,
 #DateTime<2025-02-10 20:00:00-05:00 EST America/Montreal>,
 #DateTime<2025-02-28 10:00:00-05:00 EST America/Montreal>,
 #DateTime<2025-02-28 20:00:00-05:00 EST America/Montreal>,
 #DateTime<2025-03-01 10:00:00-05:00 EST America/Montreal>,
 #DateTime<2025-03-01 20:00:00-05:00 EST America/Montreal>,
 #DateTime<2025-03-10 10:00:00-04:00 EDT America/Montreal>,
 #DateTime<2025-03-10 20:00:00-04:00 EDT America/Montreal>,
 #DateTime<2025-03-28 10:00:00-04:00 EDT America/Montreal>,
 #DateTime<2025-03-28 20:00:00-04:00 EDT America/Montreal>,
 #DateTime<2025-03-31 10:00:00-04:00 EDT America/Montreal>,
 #DateTime<2025-03-31 20:00:00-04:00 EDT America/Montreal>]

Oh and yeah in case you wonder, we support daylight saving as you can see on the example :wink:

We try to be as much possible close to cocktail to allow people switching easily to ex_cycle.

Have a good day folks :wink:

Where Next?

Popular in Libraries Top

scohen
Lexical Lexical is a next-generation language server for the Elixir programming language. Features Context aware code completion As-you...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 11851 134
New
sabiwara
Dune is a sandbox for Elixir and aims to safely evaluate user-provided code. You can try it out using this basic Elixir playground made ...
New
nikokozak
Hello all, I’ve been working on Svonix - a library for quickly integrating Svelte components into Phoenix views. It’s a much-needed succ...
New
wfgilman
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
zorbash
I created Kitto a framework for dashboards inspired by Dashing. [demo] The distributed characteristics of Elixir and the low memory foo...
New
wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
maltoe
Hello! Came here to announce ChromicPDF, a pet project PDF generator I’ve been working on for the past few months. Why another PDF gener...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
381 12391 119
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

Sub Categories:

We're in Beta

About us Mission Statement