Otter
Snippets
Otter
Upstream Otter 1.0.1 Tested
Calculate Days Between Two Dates
Compute the calendar difference in days between two date instances.
Architecture & Runtime Preview
Otter 1.0.1Zero-dependency Otter 1.0.1 snippet (Dates & Times). Copy the parameterized template or run the self-contained example.
- 1Category: Dates & Times
- 2Attribution: Otter Core Language Spec (D96)
- 3Zero external pack dependencies — paste directly into any .ot file
Source Code (2 files)
startDay is date from "${startDate}"
endDay is date from "${endDate}"
diffDays is days between startDay and endDay
startDay is date from "2026-01-01"
endDay is date from "2026-01-15"
diffDays is days between startDay and endDay
say "Days between dates:" diffDays
if diffDays is not 14
fail with "days between calculation mismatch: expected 14"
.
Installation & Usage
otter snippet inspect date-diff-days
Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.