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
- from_date (string, required) : ISO 8601 starting date, YYYY-MM-DD
- to_date (string, required) : ISO 8601 target date, YYYY-MM-DD, must be on or after from_date
Outputs
- total_days (days): Whole days from from_date to to_date
- weeks (weeks): Whole weeks in the total
- extra_days (days): Days left over after the whole weeks
Steps
- Parse from_date and to_date as proleptic Gregorian civil dates and convert both to Julian Day Numbers (Hinnant days_from_civil, cited above).
- Require to_date on or after from_date; otherwise the inputs are invalid.
- total_days = JDN(to_date) - JDN(from_date).
- weeks = floor(total_days / 7); extra_days = total_days mod 7.
Constants
None.
Sources
Worked example and test vectors
| Name | Inputs | Answer |
| 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
- Address:
cb67164bfec903b72a540c00e1bca6f7
- Made at:
2026-09-30T22:39:30.722Z
- Method sha256:
70b844d4d8e297ba24837b668de24117a7344b9600ac253c415f4be7579b641d