diff --git a/PlotLine/wwwroot/js/writer-schedule-date.js b/PlotLine/wwwroot/js/writer-schedule-date.js index 298ad63d..8f3dfe3c 100644 --- a/PlotLine/wwwroot/js/writer-schedule-date.js +++ b/PlotLine/wwwroot/js/writer-schedule-date.js @@ -22,8 +22,10 @@ const deadline = start.form.querySelector('[data-author-target-date]'); if (deadline?.dataset.defaultLocal === 'true') { - now.setMonth(now.getMonth() + 1); - deadline.value = [now.getFullYear(), now.getMonth() + 1, now.getDate()] + const nextMonth = new Date(now.getFullYear(), now.getMonth() + 1, 1); + const lastDay = new Date(now.getFullYear(), now.getMonth() + 2, 0).getDate(); + nextMonth.setDate(Math.min(now.getDate(), lastDay)); + deadline.value = [nextMonth.getFullYear(), nextMonth.getMonth() + 1, nextMonth.getDate()] .map(part => String(part).padStart(2, '0')).join('-'); } })();