题解 | #计算日期到天数转换#
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void (async function () { // Write your code here while ((line = await readline())) { let tokens = line.split(" "); let year = parseInt(tokens[0]); let month = parseInt(tokens[1]); let date = parseInt(tokens[2]); let days = 0; let dayArray = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) { if (month > 2) dayArray[1] = 29; } for (let i = 0; i < month - 1; i++) { days += dayArray[i]; } days += date; console.log(days); } })();