DatemathEx
A parsers for datemath syntax.
Installation
If available in Hex, the package can be installed
by adding datemath_ex to your list of dependencies in mix.exs:
def deps do
[
{:datemath_ex, "~> 0.1.0"}
]
endUsage
iex(1)> DatemathEx.parse "2020-01-01||+1d"
{:ok, ~U[2020-01-02 00:00:00.000Z]}
iex(2)> DatemathEx.parse "2020-01-01T12:00:00||+31d+2h"
{:ok, ~U[2020-02-01 14:00:00.000000Z]}
iex(3)> DatemathEx.parse "now-1000s/h"
{:ok, ~U[2024-05-16 08:00:00Z]}
iex(4)> DatemathEx.parse "now*1h"
{:error,
"expected ISO datetime anchor while processing UTC now anchor or ISO datetime anchor"}Missing Functionality
- Detailed Error report
- Errors for wrong ISO datetime anchors
- Timezone for ISO anchor