Date & time · real, tested code

Calculate Dates in Larzscript

Leap years, day-of-week, and day arithmetic - calendar math with the algorithm in plain view, not hidden behind a datetime object.

date is built on Howard Hinnant's days_from_civil/civil_from_days algorithm, the same pair of functions this whole ecosystem's other date-handling code is built on, so the answer you get is traceable back to real integer math, not a black box.

larzscript pkg install date

Code

import "date" as date

print(date.is_leap_year(2024))
print(date.day_of_week(2026, 12, 25))
print(date.days_between(2026, 1, 1, 2026, 12, 25))
print(date.add_days(2026, 1, 1, 100))
Output
true
5
358
{y: 2026, m: 4, d: 11}