Menkir
DatemathEx
DatemathEx is an Elixir library designed to parse datemath syntax using Combine.
Examples
- Basic addition
iex(1)> DatemathEx.parse "2020-01-01||+1d"
{:ok, ~U[2020-01-02 00:00:00.000Z]}
- Complex Expressions
iex(1)> DatemathEx.parse "2020-01-01T12:24:00||+31d+2h/h"
{:ok, ~U[2020-02-01 14:00:00Z]}
- Relative to Now
iex(1)> DatemathEx.parse "now-1000s/h"
{:ok, ~U[2024-05-16 08:00:00Z]}
- Timezone Offset
iex(1)> DatemathEx.parse "2020-01-01T12:00:00+02:00"
{:ok, ~U[2020-01-01 10:00:00.000000Z]}
- Invalid Syntax
iex(1)> DatemathEx.parse "now*1h"
{:error, "Expected at least one parser to succeed at line 1, column 0."}
Current Limitations
While DatemathEx provides robust functionality for datemath parsing, there are areas where it can be improved:
- Better Error Reporting: Enhanced error messages to provide more precise feedback on syntax errors and invalid operations.
Trending in Announcing
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...
New
Hey everyone!
Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application.
This library uses Erlang esaml to provide
plug enabl...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub.
Docs are at OpenaiEx User Gu...
New
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly.
One of i...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Other Trending Topics
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
I was thinking since Goatmire Elixir turned out pretty good I should maybe do another one. 30th of Sep - 2nd of Oct this year./
The firs...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #iex
- #elixirconf-us
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Eiji
I fully understand why you use
nimble_parsec, but if you are already working withtimexwouldn’t that be better to usecombineinstead? That would reduce dependencies ascombinewould be used anyway.Not sure if remember
nimble_parsecwell enough, i.e. not sure if we can uselabel/2in the middle of pipeline, but wouldn’t that be a more clear to read parser’s rule?With that we can:
ignore_whitespaceandignore(string/1)combinators after label which says that those are not part of a “ISO datetime anchor”Menkir
You are absolutely right. I will consider using
.
Combine. For me, it was about learning combinators and using NimbleParsec. The reason for choosing Timex came later when it was about time-shifting.