Method Deck / dates

Countdown to a date

Computes the whole number of days, and the equivalent weeks and days, from one date to another.

Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.

Try it

Inputs

Outputs

Steps

  1. Parse from_date and to_date as proleptic Gregorian civil dates and convert both to Julian Day Numbers (Hinnant days_from_civil, cited above).
  2. Require to_date on or after from_date; otherwise the inputs are invalid.
  3. total_days = JDN(to_date) - JDN(from_date).
  4. weeks = floor(total_days / 7); extra_days = total_days mod 7.

Constants

None.

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"from_date":"2026-09-30","to_date":"2026-12-25"}86 days (12 weeks and 2 days)
test vector: same date{"from_date":"2026-01-01","to_date":"2026-01-01"}0 days (0 weeks and 0 days)
test vector: across a leap day{"from_date":"2024-02-01","to_date":"2024-03-01"}29 days (4 weeks and 1 days)

Published card