feat: 订阅支持每月重置天数

This commit is contained in:
xream
2024-03-10 23:08:56 +08:00
parent 078bf228de
commit 518de2e919
4 changed files with 32 additions and 4 deletions

View File

@@ -143,3 +143,23 @@ export function validCheck(flow) {
}
}
}
export function getRmainingDays(_resetDay) {
if (!_resetDay) return;
const resetDay = parseInt(_resetDay);
if (isNaN(resetDay) || resetDay <= 0 || resetDay > 31) return;
let now = new Date();
let today = now.getDate();
let month = now.getMonth();
let year = now.getFullYear();
let daysInMonth;
if (resetDay > today) {
daysInMonth = 0;
} else {
daysInMonth = new Date(year, month + 1, 0).getDate();
}
return daysInMonth - today + resetDay;
}