возвращаемое значение fractionalSum при ошибке изменено на null

This commit is contained in:
Александр Сироткин 2022-03-17 06:42:15 +05:00
parent 2384f65999
commit b6880b9b5a

View File

@ -45,8 +45,8 @@ export const calcDuration = (start: unknown, end: unknown) => {
return (+new Date(end) - +new Date(start)) * timeInS.millisecond / timeInS.day
}
export const fractionalSum = (date: unknown, value: number, type: keyof typeof timeInS): RawDate => {
if (!isRawDate(date) || !timeInS[type] || isNaN(value ?? NaN)) return NaN
export const fractionalSum = (date: unknown, value: number, type: keyof typeof timeInS): RawDate | null => {
if (!isRawDate(date) || !timeInS[type] || isNaN(value ?? NaN)) return null
const d = new Date(date)
d.setMilliseconds(d.getMilliseconds() + value * timeInS[type] * 1000)
return d