locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
16 lines (15 loc) • 741 B
JavaScript
import { countLeapYearsBetween, normalizeCalendarYear } from "../_helpers/_calendar.js";
export function leapdays(y1, y2) {
// discuss at: https://locutus.io/python/calendar/leapdays/
// parity verified: Python 3.12
// original by: Kevin van Zonneveld (https://kvz.io)
// example 1: leapdays(2000, 2021)
// returns 1: 6
if (arguments.length === 0) {
throw new TypeError("leapdays() missing 2 required positional arguments: 'y1' and 'y2'");
}
if (arguments.length === 1) {
throw new TypeError("leapdays() missing 1 required positional argument: 'y2'");
}
return countLeapYearsBetween(normalizeCalendarYear(y1, 'leapdays'), normalizeCalendarYear(y2, 'leapdays'));
}