How many leap days belong to a multi-year data budget?

leapdays counts leap years in a half-open interval, including its starting year and excluding its ending year.

Python example and interpretation

From the start of 2020 to the start of 2024 there is one leap day. Including all of 2024 gives two. Specify whether the endpoint denotes the start or end of its year.

import calendar
[calendar.leapdays(2020,2024),calendar.leapdays(2020,2025)]

Result [1, 2]

中文

跨多个年度的数据预算如何计算闰日数量?

leapdays 对年份半开区间计数,计入起始年并排除结束年。

Python 算例与适用条件

从 2020 年起到 2024 年开始前有一个闰日;包含完整 2024 年则有两个。先区分结束日期是年初还是年末。

import calendar
[calendar.leapdays(2020,2024),calendar.leapdays(2020,2025)]

结果 [1, 2]

References / 参考来源

Keep reading / 继续阅读