summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/src/util/date.ts
blob: 9c1ab12d2c95ed6322fb5686037bbb02c4a4f242 (plain)
1
2
3
4
5
6
7
8
9
export function getWeekBounds(date: Date) {
  const offset = (date.getUTCDay() + 6) % 7
  const start = new Date(date)
  start.setUTCDate(date.getUTCDate() - offset)
  start.setUTCHours(0, 0, 0, 0)
  const end = new Date(start)
  end.setUTCDate(start.getUTCDate() + 7)
  return { start, end }
}