Skip to content

Times and scheduling

You can define ~timer declarations and durations in your recipes using the ~ symbol.

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.

[Bake] For ~{25min}.

Supported units:

  • min (minutes) — canonical preferred standard (m and minutes normalize to min).
  • 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).

CanonicalAliases
dday, days
hhr, hrs, hour, hours
mmin, mins, minute, minutes
ssec, secs, second, seconds
v1.5.0

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:

[Simmer] The @stock{2 l} for ~{1h30}.

[Rise] Let the @dough{} rise ~_{1 hr 30 mins}.

[Age] The @ham{1} in the cellar ~_{2d 4h}.
  • 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 so 1:30 isn’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).
AcceptedRejectedUse 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.

By default, a timer is exact: ~_{12h} lasts exactly 12 hours. When an operation has a variable or flexible duration, specify a range:

[Chill] Let the dough rest in the fridge ~_{12-24h}.

[Roast] The chicken for ~{40-50min}.

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 to shortest, balanced, or longest via --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 (rests does not apply).

For how ranges shape margins and kitchen visits on the run sheet, see Planning and run sheets and Plan a meal.

v1.5.0

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:

[Season] The @roast{1.2 kg} and roast ~{15 min / 500 g @&roast}. // 36 min

[Braise] The @shoulder{2 kg} ~_{1:30 h / 1 kg @&shoulder}. // 3 h

[Fry] The @cutlets{4} ~{4 min / @&cutlets}. // 16 min
  • The duration accepts any standard format (1h30, 1:30 h, or a range like 15-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 on unit_weight in 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.

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.

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.

[Whisk] The @heavy cream{} continuously for ~{5min}.

⏱️ Result: Adds 5 minutes to active time.

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.

[Bake] In the #oven for ~_{45min}.

[Prepare] Meanwhile, prepare the glaze...

⏱️ Result: Adds 0 minutes to active time, but extends idle / passive duration to ensure these 45 minutes elapse before removing the dish.

You can assign an explicit identifier right after ~ or ~_ to label a timer or queue background tasks on a shared resource.

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:

[Boil] @eggs{2} for ~eggs{3min}.

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:

[Bake] In the #oven at ^{465°F} for ~_baking{10min}.

[Bake] Lower the heat to ^{350°F} and bake for ~_baking{30min}.

⏱️ 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.

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.

## Puff pastry ~{-2d}

The puff pastry must be completed 2 days before final assembly.

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.

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.
## Puff pastry ~{-2d}

[Fold] The @butter{250g} into the @dough{500g}.

## Brioche ~{-1d 12h}

[Knead] The @flour{500g}.

## Ganache ~{-1h30}

[Pour] The @cream{200ml} over the @chocolate{200g}.

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.

Behind the scenes, Gram tracks four distinct time metrics to establish realistic schedules:

Here is how the compiler converts syntax elements into working minutes:

Syntax / ScenarioAdds to preparation timeAdds to active timeAdds 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)-

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, use perSection. Days are determined by section anchors in days (~{-1d}, ~{-2d}). Recipes without day anchors execute as a single working day, identical to upfront.

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.

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.

The compiler validates ~timer declarations and section retro-planning annotations, emitting typed warnings for malformed data:

  • Missing Unit (~timer): ~{30} without units triggers MISSING_UNIT.
  • Invalid Unit (~timer): Unrecognized units (e.g. ~{30 lightyears}) trigger INVALID_UNIT.
  • Missing Unit (section retro-planning): ~{-2}, free text, positive (~{2h}), or zero values (~{0h}) trigger MISSING_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) trigger INVALID_DURATION with 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 triggers AMBIGUOUS_NUMBER.
  • Time Paradox: Anchors conflicting with dependency order (e.g. an ingredient anchored at -10 min needed by a section anchored at -1 h) trigger TIME_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.