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