Skip to content

The open-source app everyone uses to manage agents at work

491 B
Raw Blame
export interface CostDateRange {
  from?: Date;
  to?: Date;
  allTime?: boolean;
}

/** Default reports match the UTC month used by monetary budgets. Explicit
 * bounds preserve the existing inclusive API; all-time must be requested. */
export function resolveCostDateRange(range?: CostDateRange, now = new Date()): CostDateRange {
  if (range?.allTime || range?.from || range?.to) return range;
  return { from: new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)), to: now };
}