TimeDSL syntax reference
TimeDSL compiles temporal clauses into graph conditions. A clause can restrict a calendar date, local clock minute, weekday or session age. Compilation produces data; evaluation later compares that data with the instant supplied to the engine.
Inside FlowDSL, attach a block to an edge with when time { ... }. The standalone TimeDslParser can also compile a body or an edge-prefixed block. Neither a temporal block nor a cron predicate schedules an engine call. Your application decides when to inspect or choose an edge.
Parser entry points
Section titled “Parser entry points”These methods belong to ExecKernel\Infrastructure\Importer\TimeDslParser.
| Signature | Input and result |
|---|---|
__construct(?string $referenceDate = null) |
Optional valid YYYY-MM-DD reference for only.today. An invalid supplied date is rejected. |
compile(array $lines): array |
Joins string lines. A bare body returns a list of rule records. Exactly one edge INT time { ... } block returns [{"edge_id": INT, "rules": [...]}]. |
compileInline(string $expression, ?string $referenceDate = null): ?array |
Compiles time { ... } into a rule list. An argument reference overrides the constructor reference. Returns null when the expression does not start with the word time; malformed attempted time blocks throw. |
isBlockStart(string $line): bool |
Recognises an attempted edge ... time header, including a malformed ID that compilation must reject. |
Standalone edge IDs are signed integers in PHP’s range. The parser does not resolve them against a graph. Graph attachment and reference validation belong to the importing surface.
Complete clause catalogue
Section titled “Complete clause catalogue”Clause keywords and weekday abbreviations are case-insensitive. Separate clauses with newlines or semicolons. // and /* ... */ comments are allowed outside quoted cron expressions. Nested blocks and trailing input after a closed block are rejected.
The following table shows the intermediate records returned by the parser. type identifies the rule and the other fields are operands. Graph import converts them to {"rule": TYPE, "params": {...}} and supplies the containing edge.
| Clause | Intermediate rule and operands | Constraint |
|---|---|---|
between DATE and DATE |
time_window: start_date, end_date |
Both valid calendar dates; start must not exceed end. Both days included. |
hours HH:MM-HH:MM |
time_window: start_time, end_time |
Both valid clock times. A reversed pair crosses midnight; equal values select one minute. |
weekdays mon,wed,fri |
time_window: weekdays: ["monday","wednesday","friday"] |
One or more distinct abbreviations from mon,tue,wed,thu,fri,sat,sun. Full names are not TimeDSL abbreviations. |
session.age MIN-MAX |
time_window: min_session_age, max_session_age |
Nonnegative integer seconds, no leading zeros except 0; min must not exceed max. Both bounds included. |
after TARGET |
absolute: after |
A calendar date or supported absolute date-time; inclusive lower bound. |
before TARGET |
absolute: before |
A calendar date or supported absolute date-time; inclusive upper bound. |
only.today |
time_window: equal start_date and end_date |
Requires an explicit compilation reference date. |
cron "EXPRESSION" |
cron: expression |
Nonempty quoted expression accepted by CronExpression::isValidExpression(). |
There is at most one clause of each kind per block. only.today and between share the calendar slot, so they cannot coexist. after and before are distinct and can coexist. Repeating hours after a cron clause is still a duplicate.
Literal formats
Section titled “Literal formats”| Literal | Accepted spelling |
|---|---|
| Calendar date | Exactly YYYY-MM-DD, with a real calendar date. |
| Clock time | Exactly HH:MM, from 00:00 through 23:59. |
| Absolute target | YYYY-MM-DD, or date followed by T or one space, HH:MM, optional :SS, and optional Z or signed HH:MM offset. Seconds range from 00 to 59. |
| Age bound | Decimal integer seconds within PHP’s range. Units such as 5m and decimal fractions are not accepted. |
| Cron expression | Double-quoted expression, usually five fields: minute, hour, day of month, month, day of week. The bundled cron parser also recognises @yearly, @annually, @monthly, @weekly, @daily, @midnight and @hourly. |
Date and clock literals in temporal clauses are unquoted. Relative PHP expressions such as tomorrow and unresolved TODAY placeholders are not valid replacements for dates. An offset defines an instant; it does not set the evaluation timezone for recurring hours or weekdays.
Compilation order and conjunction
Section titled “Compilation order and conjunction”Consecutive calendar, hour, weekday and session-age clauses accumulate into a time_window. An after, before or cron clause flushes the accumulated window and appends its own rule. Later window clauses start another record. All resulting conditions remain conjunctive.
For this block:
time { between 2026-12-10 and 2026-12-12 after 2026-12-10T08:30:00+01:00 hours 08:30-12:15 weekdays thu,fri cron "*/15 * * * *" session.age 0-90}The rule sequence is:
| Position | Rule | Parameters contributed |
|---|---|---|
| 1 | time_window |
Date range 10–12 December |
| 2 | absolute |
Inclusive lower instant bound |
| 3 | time_window |
Hours 08:30–12:15 and Thursday/Friday |
| 4 | cron |
Every fifteenth local minute |
| 5 | time_window |
Session age from 0 through 90 seconds |
This is a conjunction, not five alternative windows. The downloadable temporal cases include the complete compiled records for this block, each individual clause and the fixed-instant results below.
Compilation reference and evaluation time
Section titled “Compilation reference and evaluation time”Three inputs have separate roles:
| Input | Where supplied | What it controls |
|---|---|---|
| Compilation reference date | TimeDslParser constructor or compileInline() argument |
Resolves only.today to a fixed day. |
| Import clock and import timezone | SchemaImporter(clock: ..., timezoneId: ...) |
For FlowDSL, converts the supplied clock to the import timezone and passes its date to the time parser. |
| Evaluation instant and timezone | Engine TimeProvider/operation timestamp, and DateTimeEvaluator |
Determines the observed instant and its local calendar/clock interpretation when conditions run. The evaluator’s default zone is UTC. |
For example, this compilation is independent of the computer’s current date:
use ExecKernel\Infrastructure\Importer\TimeDslParser;
$rules = (new TimeDslParser('2026-12-10'))->compileInline( 'time { only.today }',);It returns [{"type":"time_window","start_date":"2026-12-10","end_date":"2026-12-10"}]. On 11 December in the evaluation zone, that condition fails. Exporting and reimporting the compiled graph retains the fixed date.
For a complete FlowDSL import, the explicit instant 2026-12-09T23:30:00Z with timezoneId: 'Europe/Madrid' resolves only.today to 2026-12-10. Setting the import timezone does not configure the engine’s DateTimeEvaluator. Without a parser reference or explicit import clock, only.today fails with EK-DSL-015.
Exact boundaries
Section titled “Exact boundaries”The following observations use DateTimeEvaluator('Europe/Madrid') and the explicit instants shown.
| TimeDSL body | Evaluation instant | Result |
|---|---|---|
hours 08:30-12:15 |
2026-12-10T08:29:59+01:00 |
Blocked |
| Same body | 2026-12-10T08:30:00+01:00 |
Allowed |
| Same body | 2026-12-10T12:15:59+01:00 |
Allowed: the whole end minute is included |
| Same body | 2026-12-10T12:16:00+01:00 |
Blocked |
after 2026-12-10T08:30:00+01:00 |
Exactly that instant | Allowed |
before 2026-12-10 |
2026-12-10T23:59:59+01:00 |
Allowed: the target is a civil day |
| Same body | 2026-12-11T00:00:00+01:00 |
Blocked |
hours 22:00-06:00; weekdays mon |
2026-12-07T23:00:00+01:00 |
Allowed |
| Same body | 2026-12-08T01:00:00+01:00 |
Blocked: the observed local weekday is Tuesday |
An overnight range does not assign the following morning to the previous weekday. Calendar dates and weekdays describe the current local day.
session.age 30-90 permits elapsed ages 30 and 90 seconds, and blocks 29 and 91. Age is measured from the session’s createdAt in elapsed seconds; a future creation timestamp cannot satisfy it. This condition does not configure session expiration.
TimeDSL after/before are inclusive because they compile to absolute. The separate built-in time rule uses strict after/before operators on its chosen source; equality fails there. Use that rule’s full parameter form when your requirement is “strictly before this instant”. See the rule reference.
Daylight-saving transitions
Section titled “Daylight-saving transitions”Recurring windows and cron compare the observed local calendar minute. During the Madrid clock change on 25 October 2026, the following instants are one hour apart but have the same local clock label:
| Expression | First occurrence | Second occurrence | Result |
|---|---|---|---|
time { hours 02:15-02:45 } |
2026-10-25T02:30:00+02:00 |
2026-10-25T02:30:00+01:00 |
Both allowed |
time { cron "30 2 * * *" } |
Same first instant | Same second instant | Both allowed |
A cron condition has no memory of a previous match and does not provide once-per-day execution. During a spring gap, an absent local minute has no actual instant at which it can match.
Absolute offset-free targets have a different requirement: they must resolve to exactly one instant in the evaluation zone. In Madrid, 2026-10-25T02:30:00 is ambiguous and 2026-03-29T02:30:00 does not exist. Both fail temporal parameter validation at evaluation. TimeDSL compilation checks their spelling without inventing a timezone, so successful compilation alone does not establish that they resolve in the eventual zone.
Use 2026-10-25T02:30:00+02:00 or 2026-10-25T02:30:00+01:00 to select the intended occurrence. The explicit offset identifies the instant even when its local label repeats.
Errors and invalid forms
Section titled “Errors and invalid forms”TimeDslException carries ekCode and a context reason; some reasons add the offending value, clause or bounds.
| Code | Typical reason / correction |
|---|---|
EK-DSL-002 |
invalid_block_header: repair time { ... } or the standalone edge header. |
EK-DSL-003 |
missing_closing_brace: close the attempted block. |
EK-DSL-006 |
invalid_date_range: order the calendar endpoints. |
EK-DSL-008 |
invalid_weekday: use distinct supported abbreviations. |
EK-DSL-009 |
invalid_session_age_range: min must not exceed max. |
EK-DSL-010 |
invalid_expression: unsupported clause, nested block, unfinished quote or comment. |
EK-DSL-011 |
invalid_date: use a valid absolute date or date-time. |
EK-DSL-012 |
invalid_time: repair hours, minutes, seconds or offset components. |
EK-DSL-014 |
duplicate_clause: remove the repeated kind, including the shared calendar slot. |
EK-DSL-015 |
missing_reference_date or unresolved_today_marker: supply an explicit reference and retain its compiled dates. |
EK-DSL-016 |
trailing_block_input: consume exactly one block. |
EK-DSL-017 |
empty_time_block: include at least one actual clause. |
EK-DSL-018 |
invalid_cron_expression: correct the quoted cron expression. |
EK-DSL-019 |
invalid_integer: correct an edge ID or age bound, including overflow. |
A reversed clock range such as 22:00-06:00 is valid overnight syntax, not an inverted-date error. Runtime parameter failures such as an ambiguous local absolute target use rule diagnostics, including EK-RULE-002, rather than a TimeDSL parse code. The temporal conditions guide develops engine wiring and application use; Error codes and exceptions covers the error boundaries.