fix: Set date hours to 9 in snooze time (#7426)

This commit is contained in:
Muhsin Keloth
2023-06-29 14:38:03 +05:30
committed by GitHub
parent 28e7a5d228
commit dc1a41b136
2 changed files with 8 additions and 1 deletions

View File

@@ -8,6 +8,8 @@ import {
isMonday, isMonday,
isToday, isToday,
setHours, setHours,
setMinutes,
setSeconds,
} from 'date-fns'; } from 'date-fns';
import wootConstants from 'dashboard/constants/globals'; import wootConstants from 'dashboard/constants/globals';
@@ -36,7 +38,7 @@ export const findNextDay = currentDate => {
}; };
export const setHoursToNine = date => { export const setHoursToNine = date => {
return setHours(date, 9, 0, 0); return setSeconds(setMinutes(setHours(date, 9), 0), 0);
}; };
export const findSnoozeTime = (snoozeType, currentDate = new Date()) => { export const findSnoozeTime = (snoozeType, currentDate = new Date()) => {

View File

@@ -40,6 +40,11 @@ describe('#Snooze Helpers', () => {
nextDay.setHours(9, 0, 0, 0); nextDay.setHours(9, 0, 0, 0);
expect(setHoursToNine(nextDay)).toEqual(nextDay); expect(setHoursToNine(nextDay)).toEqual(nextDay);
}); });
it('should return date with 9.00AM time if date with 10am is passes', () => {
const nextDay = new Date('06/17/2023 10:00:00');
nextDay.setHours(9, 0, 0, 0);
expect(setHoursToNine(nextDay)).toEqual(nextDay);
});
}); });
describe('findSnoozeTime', () => { describe('findSnoozeTime', () => {