Skip to content

Commit bf49224

Browse files
authored
Releases v3.4.0 (#41)
1 parent c6413d6 commit bf49224

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,22 @@ test/predicator/
149149

150150
## Recent Additions (2025)
151151

152+
### Durations and Relative Dates (v3.4.0)
153+
154+
- Natural-language durations and relative time expressions
155+
- Relative dates: `3d ago`, `2w from now`, `next 1mo`, `last 1y`
156+
- Date/DateTime arithmetic: `#2024-01-10# + 5d`, `#2024-01-15T10:30:00Z# - 2h`
157+
- Grammar updates: `duration` and `relative_date` productions
158+
- Full pipeline support (lexer, parser, compiler, evaluator, string visitor) with tests
159+
- Examples:
160+
161+
```elixir
162+
Predicator.evaluate("created_at > 3d ago", %{"created_at" => ~U[2024-01-20 00:00:00Z]})
163+
Predicator.evaluate("due_at < 2w from now", %{"due_at" => Date.add(Date.utc_today(), 10)})
164+
Predicator.evaluate("#2024-01-10# + 5d = #2024-01-15#", %{})
165+
Predicator.evaluate("#2024-01-15T10:30:00Z# - 2h < #2024-01-15T10:30:00Z#", %{})
166+
```
167+
152168
### Object Literals (v3.1.0 - JavaScript-Style Objects)
153169

154170
- **Syntax Support**: Complete JavaScript-style object literal syntax (`{}`, `{name: "John"}`, `{user: {role: "admin"}}`)

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [3.4.0] - 2025-09-09
11+
12+
### Added
13+
14+
#### Durations and relative date/time arithmetic
15+
16+
- New duration literals and relative date expressions (e.g., `3d ago`, `2w from now`, `next 1mo`, `last 1y`)
17+
- Date and DateTime arithmetic using durations (e.g., `#2024-01-10# + 5d`, `#2024-01-15T10:30:00Z# - 2h`)
18+
- Grammar additions: `duration` and `relative_date` productions
19+
- Full pipeline support (lexer, parser, compiler, evaluator, string visitor) with tests
20+
21+
#### Examples:
22+
23+
```elixir
24+
Predicator.evaluate("created_at > 3d ago", %{"created_at" => ~U[2024-01-20 00:00:00Z]})
25+
Predicator.evaluate("due_at < 2w from now", %{"due_at" => Date.add(Date.utc_today(), 10)})
26+
Predicator.evaluate("#2024-01-10# + 5d = #2024-01-15#", %{})
27+
Predicator.evaluate("#2024-01-15T10:30:00Z# - 2h < #2024-01-15T10:30:00Z#", %{})
28+
```
29+
30+
### Documentation
31+
32+
- Updated EBNF grammar in docs
33+
- Added AGENTS.md with model-agnostic agent guidance; `CLAUDE.md` now references the same content
34+
1035
## [3.3.0] - 2025-08-31
1136

1237
### Added

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Predicator allows you to safely evaluate user-defined expressions without the se
1919
- 🔄 **Reversible**: Convert AST back to string expressions with formatting options
2020
- 🧮 **Arithmetic**: Full arithmetic operations (`+`, `-`, `*`, `/`, `%`) with proper precedence
2121
- 📅 **Date Support**: Native date and datetime literals with ISO 8601 format
22+
-**Durations & Relative Dates**: Natural-language durations and relative time expressions with date arithmetic
2223
- 📋 **Lists**: List literals with membership operations (`in`, `contains`)
2324
- 🧠 **Smart Logic**: Logical operators with proper precedence (`AND`, `OR`, `NOT`)
2425
- 🔧 **Functions**: Built-in functions for string, numeric, and date operations
@@ -32,7 +33,7 @@ Add `predicator` to your list of dependencies in `mix.exs`:
3233
```elixir
3334
def deps do
3435
[
35-
{:predicator, "~> 3.3"}
36+
{:predicator, "~> 3.4"}
3637
]
3738
end
3839
```
@@ -58,6 +59,19 @@ true
5859
iex> Predicator.evaluate!("created_at < #2024-01-15T10:30:00Z#", %{"created_at" => ~U[2024-01-10 09:00:00Z]})
5960
true
6061

62+
# Durations, relative dates, and date arithmetic
63+
iex> Predicator.evaluate!("created_at > 3d ago", %{"created_at" => ~U[2024-01-20 00:00:00Z]})
64+
true
65+
66+
iex> Predicator.evaluate!("due_at < 2w from now", %{"due_at" => Date.add(Date.utc_today(), 10)})
67+
true
68+
69+
iex> Predicator.evaluate!("#2024-01-10# + 5d = #2024-01-15#", %{})
70+
true
71+
72+
iex> Predicator.evaluate!("#2024-01-15T10:30:00Z# - 2h < #2024-01-15T10:30:00Z#", %{})
73+
true
74+
6175
# List literals and membership
6276
iex> Predicator.evaluate!("role in ['admin', 'manager']", %{"role" => "admin"})
6377
true
@@ -334,6 +348,9 @@ iex> Predicator.evaluate("'coding' in user.hobbies", list_context)
334348
- **Booleans**: `true`, `false` (or plain identifiers like `active`, `expired`)
335349
- **Dates**: `#2024-01-15#` (ISO 8601 date format)
336350
- **DateTimes**: `#2024-01-15T10:30:00Z#` (ISO 8601 datetime format with timezone)
351+
- **Durations**: Natural units for time spans (e.g., `3d`, `2h`, `15m`)
352+
- In relative expressions: `3d ago`, `2w from now`, `next 1mo`, `last 1y`
353+
- In arithmetic: `#2024-01-10# + 5d`, `#2024-01-15T10:30:00Z# - 2h`
337354
- **Lists**: `[1, 2, 3]`, `['admin', 'manager']` (homogeneous collections)
338355
- **Objects**: `{}`, `{name: "John", age: 30}`, `{user: {role: "admin"}}` (JavaScript-style object literals)
339356
- **Identifiers**: `score`, `user_name`, `is_active`, `user.profile.name`, `user['key']`, `items[0]` (variable references with dot notation and bracket notation for nested data)
@@ -554,4 +571,3 @@ mix dialyzer # Type checking
554571
## Documentation
555572

556573
Full documentation is available at [HexDocs](https://hexdocs.pm/predicator).
557-

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Predicator.MixProject do
22
use Mix.Project
33

44
@app :predicator
5-
@version "3.3.0"
5+
@version "3.4.0"
66
@description "A secure, non-evaling condition (boolean predicate) engine for end users"
77
@source_url "https://github.com/riddler/predicator-ex"
88
@deps [

0 commit comments

Comments
 (0)