diff --git a/.inscode b/.inscode index ecc8bdde946f464a2c4d431d8f8196413737d922..e1777316cc8a34b6c53f0ae12504b6c66fbdb272 100644 --- a/.inscode +++ b/.inscode @@ -1,6 +1,10 @@ run = "npm i && npm run dev" +language = "node" [env] PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" XDG_CONFIG_HOME = "/root/.config" -npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" \ No newline at end of file +npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" + +[debugger] +program = "main.js" diff --git a/index.js b/index.js index 2d7e6834fb6366b3120c7a37cc5f637bc4a33928..24a7ace91b4a2e5d07e7acd2dcc67f1e43536419 100644 --- a/index.js +++ b/index.js @@ -1 +1,24 @@ -console.log("欢迎来到 InsCode"); \ No newline at end of file +function 计算当前月一共有几天() { + // 获取当前年份和月份 + const year = new Date().getFullYear(); + const month = new Date().getMonth() + 1; // 注意月份是从0开始的,需要加1 + + // 计算当前月份的天数 + const daysInMonth = new Date(year, month, 0).getDate(); + + return daysInMonth; +} +const days = 计算当前月一共有几天(); +console.log(days); // 输出当前月份的天数 + +function getDayOfMonth() { + const today = new Date(); + const year = today.getFullYear(); + const month = today.getMonth(); + const firstDayOfMonth = new Date(year, month, 1); + const diffMs = today.getTime() - firstDayOfMonth.getTime(); + const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24)); + return diffDays; +} +const dayOfMonth = getDayOfMonth(); +console.log(`今天是本月的第 ${dayOfMonth} 天`);