Counts the whole days between two calendar dates, inclusive or exclusive of both endpoints.
Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.
Try it
Inputs
date_a (string, required) : Earlier ISO 8601 date, YYYY-MM-DD
date_b (string, required) : Later or equal ISO 8601 date, YYYY-MM-DD
inclusive (boolean, required) : If true, count both date_a and date_b as elapsed days; if false, count only the nights between them
Outputs
days (days): Number of days between the two dates under the chosen rule
Steps
Parse date_a and date_b as proleptic Gregorian civil dates (year, month, day).
Convert each date to a Julian Day Number (JDN) using the Fliegel and Van Flandern (1968) day-count method, implemented here via the equivalent Hinnant days_from_civil algorithm (cited above).
Require date_b to be on or after date_a; otherwise the inputs are invalid.
diff = JDN(date_b) - JDN(date_a). This is the exclusive count: the number of nights, or day-boundaries crossed, between the two dates.
If inclusive is true, days = diff + 1 (both endpoint calendar days are counted). If inclusive is false, days = diff.
Constants
None.
Sources
chrono-Compatible Low-Level Date Algorithms (Howard Hinnant, 2026-09-30T19:41:35Z) - days_from_civil / civil_from_days, the day-number kernel used by this method; verified against 1970-01-01 -> JDN 2440588 and 2000-01-01 -> JDN 2451545