Duration is a Zed extension that adds code actions for calculating time ranges in Markdown and Plain Text buffers.
- Markdown and Plain Text only
- Code actions for the current line or current selection
- Time-range syntax using
- - Pure Rust time parsing and duration math with no external conversion dependency
Place the cursor on a line such as 10:00 - 12:00, 14:00 - 17:00, or 23:00 - 2:00, then open code actions in Zed and choose one of these actions:
Calculate durationCalculate duration on line
The extension rewrites the text to include the result, for example 10:00 - 12:30 = 2.5 hours.
This repository pins Rust 1.94.0 via rust-toolchain.toml for consistent local builds.
The Zed extension itself is compiled for wasm32-wasip2, so make sure that target is installed too.
-
Install the language server binary on your
PATH:cargo install --path language-server
-
Install the Rust target Zed needs for compiling the extension:
rustup target add wasm32-wasip2 --toolchain 1.94.0
-
Install this repository as a dev extension in Zed with
zed: install dev extension. -
Test from a saved Markdown or Plain Text file.
Supported v1 input examples:
10:00 - 12:00 = 2 hours14:00 - 17:00 = 3 hours23:00 - 2:00 = 3 hours9:00 - 11:15 = 2.25 hours
cargo check -p duration
cargo test -p duration-language-server- The outer parser is intentionally small and only owns the time-range syntax on each line.
- Cross-midnight ranges are treated as next-day durations when the end time is earlier than the start time.
- v1 only supports 24-hour
H:MMandHH:MMinput.