mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-10 20:50:08 +02:00
13 lines
491 B
TypeScript
13 lines
491 B
TypeScript
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 };
|
|
}
|