MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getWeekStart

Function getWeekStart

packages/billing/src/subscription.ts:124–132  ·  view source on GitHub ↗
(
  billingPeriodStart: Date,
  now: Date = new Date(),
)

Source from the content-addressed store, hash-verified

122 * Weeks start on the same day-of-week as the billing period started.
123 */
124export function getWeekStart(
125 billingPeriodStart: Date,
126 now: Date = new Date(),
127): Date {
128 const billingDayOfWeek = billingPeriodStart.getUTCDay()
129 const currentDayOfWeek = now.getUTCDay()
130 const daysBack = (currentDayOfWeek - billingDayOfWeek + 7) % 7
131 return startOfDay(addDays(now, -daysBack))
132}
133
134/**
135 * Get the end of the current billing-aligned week (start of next week).

Callers 3

getWeekEndFunction · 0.70
getWeeklyUsageFunction · 0.70

Calls 2

startOfDayFunction · 0.85
addDaysFunction · 0.85

Tested by

no test coverage detected