Times and scheduling
You can define ~timer declarations and durations in your recipes using the ~ symbol.
Writing a duration
Section titled “Writing a duration”Every ~timer requires a recognizable duration and unit inside braces (~{25min}); free-text durations like ~{about 10 minutes} or ~{half an hour} trigger a compiler warning.
Supported units:
min(minutes) — canonical preferred standard (mandminutesnormalize tomin).h(hours).d(days).s(seconds).
Units resolve through Gram’s multi-language time dictionary, so localized aliases work regardless of the recipe language (~{2j} equals ~{2d}, and ~{1 hr} works anywhere).
| Canonical | Aliases |
|---|---|
d | day, days |
h | hr, hrs, hour, hours |
m | min, mins, minute, minutes |
s | sec, secs, second, seconds |
Natural and compound forms
Section titled “Natural and compound forms”Write durations the way recipes naturally do. Spaces don’t matter (~{1h30}, ~{1 h 30}, ~{1 hr 30 mins} all mean 1 h 30 min), and every view formats them consistently in the reader’s language:
- Compound units (
~{1h30min},~{2 d 4 h},~{1h + 30min}): list units from largest to smallest, each once. A trailing number without a unit is allowed right after hours (minutes) or minutes (seconds) if it is a whole number under 60 (~{1h30},~{2min30}, not~{1h75}). With its unit written out, a number is read as written, even past 60:~{1 h 75 min}is 2 h 15 min. Decimals and fractions only apply to single-unit durations (~{1.5 h},~{1½ h}, not~{1.5h30}). - Clock notation (
~{1:30:00},~{1:30 h},~{4:30 min}): three parts always work (hh:mm:ss); two parts require a leading unit so1:30isn’t ambiguous between hours and minutes. - Prime notation (
~{5'},~{5'30"},~{45"}):'counts whole minutes and"counts whole seconds (typographic quotes’,′,″, and''also work). Primes read like a clock: after minutes, seconds stay under 60 (~{6'30"}, not~{5'90"}). - Decimals (
~{1.5 h},~{1,5 h}): periods and commas both work (see decimal numbers).
| Accepted | Rejected | Use instead |
|---|---|---|
~{1h30}, ~{1 hr 30}, ~{1h + 30min} | ~{1:30} (ambiguous) | ~{1h30} or ~{1:30 min} |
~{1:30 h}, ~{1:30:00} | ~{1h75} (≥ 60 min) | ~{2h15} |
~{4'30"}, ~{4min30} | ~{30min 1h} (wrong order) | ~{1h30} |
~{1.5 h}, ~{1,5 h}, ~{1½ h} | ~{1.5h30} (decimal in compound) | ~{1h30} or ~{1.5 h} |
~{45 min - 1 h}, ~{1h30-2h} | ~{half an hour} (words) | ~{30min} |
Unrecognized durations raise an INVALID_DURATION warning with a suggested fix and are excluded from total times.
Exact times and ranges
Section titled “Exact times and ranges”By default, a timer is exact: ~_{12h} lasts exactly 12 hours. When an operation has a variable or flexible duration, specify a range:
Write the shorter duration first, following the duration formats above. You can omit the left-hand unit only when it is a bare number and the right side has a single unit (~{1-2 h}, ~{5-7'}, ~{1:30-2:00 h}); for compound or mixed-unit bounds, write both sides in full (~_{2h30-3h}, ~{45 min - 1 h}).
Ranges behave differently depending on whether the timer is passive or active:
- Passive range (
~_{12-24h}) — elasticity: “ready from 12 hours, optimal up to 24 hours.” By default, timelines use the shortest bound (configurable toshortest,balanced, orlongestvia--rests/gram.rests), and calendar planning can stretch or compress it within those bounds to fit your kitchen hours. - Active range (
~{40-50min}) — safety margin: planned on the longest bound (50 minutes) so service is never delayed (restsdoes not apply).
For how ranges shape margins and kitchen visits on the run sheet, see Planning and run sheets and Plan a meal.
Proportional times
Section titled “Proportional times”Some cooking times scale with weight or count—such as 15 minutes per 500 g of roast, or 4 minutes per cutlet. Write the duration, a slash, and the reference amount of an ingredient declared earlier in the section, following the same syntax as a ratio with units:
- The duration accepts any standard format (
1h30,1:30 h, or a range like15-20 min), while the target amount must be a single number. - A time per piece applied to a weight (
~{4 min / @&cutlets}with@cutlets{800 g}) relies onunit_weightin your ingredient database; if missing, the timer stays uncomputed with a warning. - Scaling the recipe recalculates proportional times and updates the schedule automatically.
- Multipliers (
~{15 min / 500 g @&roast * 2}) and proportional section anchors are not supported yet.
Active vs passive
Section titled “Active vs passive”The Gram compiler builds a complete execution timeline for each recipe. To achieve realistic scheduling, it distinguishes hands-on kitchen work from autonomous background tasks.
Active (default)
Section titled “Active (default)”By default, a ~timer is active. It requires direct hands-on involvement: the step is blocking and demands undivided attention before moving on to subsequent operations.
⏱️ Result: Adds 5 minutes to active time.
Passive (_)
Section titled “Passive (_)”Add the _ modifier to designate a passive ~timer. This represents a background task. You initiate the timer (e.g. putting a dish into the oven) and can immediately proceed with subsequent steps.
⏱️ Result: Adds 0 minutes to active time, but extends idle / passive duration to ensure these 45 minutes elapse before removing the dish.
Naming timers and tracks
Section titled “Naming timers and tracks”You can assign an explicit identifier right after ~ or ~_ to label a timer or queue background tasks on a shared resource.
Timer labels
Section titled “Timer labels”When multiple operations run concurrently (like eggs boiling while a stock simmers), naming a timer allows user interfaces and run sheets to track each process clearly:
Sequential passive timers (named tracks)
Section titled “Sequential passive timers (named tracks)”By default, passive timers run concurrently with the rest of the recipe. However, certain background operations sharing equipment cannot physically overlap (e.g. blind-baking a crust for 10 minutes, then lowering the heat and continuing baking for 30 minutes in the same oven).
To enforce sequential execution of passive timers, give them the same track name:
⏱️ Result: Because both timers share the track name
baking, Gram places them on the same background track. The 30-minute timer will only start after the 10-minute timer completes. Idle waiting time increases by 40 minutes, while active hands-on time remains zero.
Section retro-planning
Section titled “Section retro-planning”Adding a ~{...} annotation to a ## Section header defines an anticipation deadline. This tells the compiler when the section must conclude relative to the final step where it is consumed.
This acts as a temporal anchor. An annotation like ~{-2d} instructs the compiler to complete this section 2 full days before it is needed in subsequent steps.
To ensure positive relative timestamps starting at 0, the compiler normalizes the timeline: this anticipated section becomes the new start point (Time 0), and all subsequent operations are shifted proportionally. Its mise en place moves accordingly, scheduled immediately before the section, two days prior to service.
The puff pastry must be completed 2 days before final assembly.
Days and hours
Section titled “Days and hours”The chosen unit defines the anchor’s semantics:
- An anchor in days (
~{-1d},~{-2d}) opens a distinct working day (day before, two days before), anchoring the “by working day” strategy and day labels (D-1, D-2). - An anchor in hours or minutes (
~{-18h},~{-90min}) specifies a precise deadline within that section’s scheduled day, without opening a new working day.
Working days are designed to fit within a 24-hour span: if a long passive duration pushes a day’s work out of its window (such as a ~{-1d} dough fermenting for 50 hours), the compiler emits DAY_OVERFLOW and recommends anchoring the section further back.
Strict syntax
Section titled “Strict syntax”Section header retro-planning annotations require a strictly negative duration:
- A required leading
-sign. - A non-zero duration in days, hours, or minutes (compound and clock forms are both supported; see Writing a duration).
- A single duration—anchors cannot be ranges or include seconds.
Free prose (~{the day before}), positive values (~{2h}), and zero values (~{0h}) are invalid and trigger compiler warnings.
Units resolve through the multi-language time dictionary used by ~timer: j, jour, and jours are recognized aliases for d.
See also: Retro-planning (Scheduling) in the document structure reference.
How time is calculated
Section titled “How time is calculated”Behind the scenes, Gram tracks four distinct time metrics to establish realistic schedules:
Cheat sheet: what adds time?
Section titled “Cheat sheet: what adds time?”Here is how the compiler converts syntax elements into working minutes:
| Syntax / Scenario | Adds to preparation time | Adds to active time | Adds to passive time |
|---|---|---|---|
New ingredient (@flour) | + 1 min (to fetch) | - | - |
Intermediate (&dough) | + 1 min (to weigh where consumed) | - | - |
Prep shorthand (@onion(peeled)) | + 2 min | - | - |
Cookware (#pan) | + 1 min (to fetch) | - | - |
Active timer (~{10min}) | - | + 10 min | - |
Passive timer (~_{1h}) | - | - | + 1 hour (background) |
| Step without any timer | - | + 2 min (default fallback) | - |
When the mise en place happens
Section titled “When the mise en place happens”Each section has its own mise en place (gathering and preparing ingredients and cookware). Gram supports three layout strategies without requiring any changes to the recipe source text:
- By section (
perSection, default): mise en place is scheduled immediately prior to that section. An ingredient needed two days later is not fetched prematurely, and preparation can occur during passive waiting times of earlier steps (masked time). - All at the start (
upfront): all prep tasks are grouped at the beginning before active cooking starts. Except for intermediate preparations, which cannot be weighed before they are produced. - By working day (
perDay): for multi-day recipes, preparation tasks for each day are grouped at the start of that day, even if you cook in several visits. To take things out right before each visit, useperSection. Days are determined by section anchors in days (~{-1d},~{-2d}). Recipes without day anchors execute as a single working day, identical toupfront.
Two considerations for multi-day recipes:
- A long passive timer is not an anchor. A
~_{48h}passive duration shifts the timeline two days earlier, but only an explicit section anchor formally opens a separate working day (e.g.## Cream ~{-2d}). - An anchor in hours never opens a day. An anchor such as
~{-18h}or~{-36h}represents an explicit deadline within that section’s day, not an independent working day. To schedule a previous working day, use~{-1d}(see Days and hours).
Strategy selection happens at render time: the Playground features a dropdown selector, VS Code provides the gram.miseEnPlace setting, the CLI exposes the --mise-en-place flag, and the renderer accepts miseEnPlace. This setting influences total duration and idle time, as well as the placement of the preparation in the schedule, while keeping active preparation and hands-on cooking times invariant.
An intermediate preparation (&dough) is weighed in the section that consumes it and never before it is produced: even in upfront mode, it is scheduled as a deferred block immediately before the consuming section.
Smart dependency tracking (ALAP)
Section titled “Smart dependency tracking (ALAP)”Gram natively implements an As Late As Possible (ALAP) scheduling algorithm. If a dough requires ~_{1h} passive fermentation in the background and a subsequent step depends on it, the compiler plans its kneading at the latest possible moment: fermentation finishes exactly when the next step begins, preventing dough from sitting over-proofed on the counter.
For a deeper architectural exploration, see the ALAP scheduling deep dive.
Error handling
Section titled “Error handling”The compiler validates ~timer declarations and section retro-planning annotations, emitting typed warnings for malformed data:
- Missing Unit (
~timer):~{30}without units triggersMISSING_UNIT. - Invalid Unit (
~timer): Unrecognized units (e.g.~{30 lightyears}) triggerINVALID_UNIT. - Missing Unit (section retro-planning):
~{-2}, free text, positive (~{2h}), or zero values (~{0h}) triggerMISSING_UNIT. - Invalid Unit (section retro-planning): Unrecognized units trigger
INVALID_UNIT. - Invalid Duration: Unrecognized or ambiguous duration formats (
~{1:30},~{1h75},~{30min 1h},~{1-2h30},~{half an hour}, or ranges/seconds in anchors) triggerINVALID_DURATIONwith a suggested fix; the timer is excluded from total time and the anchor is ignored. - Ambiguous Number: A comma followed by three digits (
~{1,000 min},~{-1,000h}) is parsed as a decimal (1) and triggersAMBIGUOUS_NUMBER. - Time Paradox: Anchors conflicting with dependency order (e.g. an ingredient anchored at
-10 minneeded by a section anchored at-1 h) triggerTIME_PARADOX. - Track Contention: Concurrent passive timers delayed on the same named track trigger
TRACK_CONTENTION. - Day overflow: Passive durations pushing working day tasks beyond the 24-hour window trigger
DAY_OVERFLOW. - Duration Out Of Range: Durations exceeding 1,000 years are capped and trigger
DURATION_OUT_OF_RANGE.
Warnings are non-blocking by default, but can be enforced as errors via gram check --strict.