fix: 修复获取下次提醒时间判定错误 & close #20
This commit is contained in:
parent
d7a8eeee7a
commit
085bba9d36
@ -46,7 +46,7 @@ const genNextRemindTimeWithCHS = (remindTime) => {
|
||||
if (frequency === 'daily') {
|
||||
const remindMoment = moment().hour(hour).minute(minute);
|
||||
// 判断当前时间是否已经过了今天的提醒时间
|
||||
if (remindMoment.isBefore(nowMoment)) {
|
||||
if (remindMoment.isSameOrBefore(nowMoment)) {
|
||||
// 如果已经过了,那么下次提醒时间为明天的提醒时间
|
||||
remindMoment.add(1, 'day');
|
||||
}
|
||||
@ -61,7 +61,7 @@ const genNextRemindTimeWithCHS = (remindTime) => {
|
||||
return daysOfWeek.reduce(({ nextRemindTime, nextRemindTimeCHS }, dayOfWeek) => {
|
||||
const remindMoment = moment().hour(hour).minute(minute).isoWeekday(dayOfWeek);
|
||||
// 判断当前时间是否已经过了本周的提醒时间
|
||||
if (remindMoment.isBefore(nowMoment)) {
|
||||
if (remindMoment.isSameOrBefore(nowMoment)) {
|
||||
// 如果已经过了,那么下次提醒时间为下周的提醒时间
|
||||
remindMoment.add(1, 'week');
|
||||
}
|
||||
@ -86,7 +86,7 @@ const genNextRemindTimeWithCHS = (remindTime) => {
|
||||
const dayOfMonthNum = moment().daysInMonth();
|
||||
const remindMoment = moment().hour(hour).minute(minute).date(dayOfMonthNum < dayOfMonth ? dayOfMonthNum : dayOfMonth);
|
||||
// 判断当前时间是否已经过了本月的提醒时间
|
||||
if (remindMoment.isBefore(nowMoment)) {
|
||||
if (remindMoment.isSameOrBefore(nowMoment)) {
|
||||
// 如果已经过了,那么下次提醒时间为下月的提醒时间,需要重新判断一下是否有31号
|
||||
const nextDayOfMonthNum = moment().add(1, 'month').daysInMonth();
|
||||
remindMoment.add(1, 'month').date(nextDayOfMonthNum < dayOfMonth ? nextDayOfMonthNum : dayOfMonth);
|
||||
@ -114,7 +114,7 @@ const genNextRemindTimeWithCHS = (remindTime) => {
|
||||
const dayOfMonthNum = moment().month(month).daysInMonth();
|
||||
const remindMoment = moment().hour(hour).minute(minute).month(month).date(dayOfMonthNum < dayOfMonth ? dayOfMonthNum : dayOfMonth);
|
||||
// 判断当前时间是否已经过了今年的提醒时间
|
||||
if (remindMoment.isBefore(nowMoment)) {
|
||||
if (remindMoment.isSameOrBefore(nowMoment)) {
|
||||
// 如果已经过了,那么下次提醒时间为明年的提醒时间,需要重新判断一下是否有29号
|
||||
const nextDayOfMonthNum = moment().add(1, 'year').month(month).daysInMonth();
|
||||
remindMoment.add(1, 'year').date(nextDayOfMonthNum < dayOfMonth ? nextDayOfMonthNum : dayOfMonth);
|
||||
@ -130,7 +130,7 @@ const genNextRemindTimeWithCHS = (remindTime) => {
|
||||
// 今天是否是工作日
|
||||
const isWorkday = judgeIsWorkDay();
|
||||
// 如果今天非工作日或者如果是工作日,且当前时间过了提醒时间,那么下次提醒时间为下次工作日的提醒时间
|
||||
if (!isWorkday || (isWorkday && remindMoment.isBefore(nowMoment))) {
|
||||
if (!isWorkday || (isWorkday && remindMoment.isSameOrBefore(nowMoment))) {
|
||||
remindMoment.add(1, 'day');
|
||||
while (!judgeIsWorkDay(remindMoment)) {
|
||||
remindMoment.add(1, 'day');
|
||||
@ -147,7 +147,7 @@ const genNextRemindTimeWithCHS = (remindTime) => {
|
||||
// 今天是否是工作日
|
||||
const isWorkday = judgeIsWorkDay();
|
||||
// 如果今天是工作日或者如果是非工作日,且当前时间过了提醒时间,那么下次提醒时间为下次非工作日的提醒时间
|
||||
if (isWorkday || (!isWorkday && remindMoment.isBefore(nowMoment))) {
|
||||
if (isWorkday || (!isWorkday && remindMoment.isSameOrBefore(nowMoment))) {
|
||||
remindMoment.add(1, 'day');
|
||||
while (judgeIsWorkDay(remindMoment)) {
|
||||
remindMoment.add(1, 'day');
|
||||
|
Loading…
x
Reference in New Issue
Block a user