Skip to content

Commit

Permalink
recurring: add 15 minutes to the end time
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytroshch committed Sep 11, 2023
1 parent 50022c0 commit 62b1ef6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/util/date.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
isValid, format, startOfDay, addDays,
isValid, format, startOfDay, addDays, addMinutes,
} from 'date-fns'
import Debug from 'debug'
import i18n, { DATE_FNS_LOCALES, LANGUAGES } from '../locales/i18n'
Expand Down Expand Up @@ -66,6 +66,9 @@ export const roundDay = (firstDate, secondDate) => {
const roundedFirstDateMs = startOfDay(firstDate).getTime()
const secondDateMs = new Date(secondDate).getTime()

const daysDifference = Math.floor((secondDateMs - roundedFirstDateMs) / TIMEFRAME_WIDTHS['1D'])
return addDays(firstDate, daysDifference)
const daysDifference = Math.floor(
(secondDateMs - roundedFirstDateMs) / TIMEFRAME_WIDTHS['1D'],
)
// add 15 minutes to the end time
return addMinutes(addDays(firstDate, daysDifference), 15)
}

0 comments on commit 62b1ef6

Please sign in to comment.