UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

25 lines (24 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.weekday = weekday; const _calendar_ts_1 = require("../_helpers/_calendar.js"); function weekday(year, month, day) { // discuss at: https://locutus.io/python/calendar/weekday/ // parity verified: Python 3.12 // original by: Kevin van Zonneveld (https://kvz.io) // example 1: weekday(2024, 2, 29) // returns 1: 3 if (arguments.length === 0) { throw new TypeError("weekday() missing 3 required positional arguments: 'year', 'month', and 'day'"); } if (arguments.length === 1) { throw new TypeError("weekday() missing 2 required positional arguments: 'month' and 'day'"); } if (arguments.length === 2) { throw new TypeError("weekday() missing 1 required positional argument: 'day'"); } const normalizedYear = (0, _calendar_ts_1.normalizeCalendarYear)(year, 'weekday'); const normalizedMonth = (0, _calendar_ts_1.normalizeCalendarMonth)(month, 'weekday'); const normalizedDay = (0, _calendar_ts_1.normalizeCalendarDay)(normalizedYear, normalizedMonth, day, 'weekday'); return (0, _calendar_ts_1.pythonWeekday)(normalizedYear, normalizedMonth, normalizedDay); }